
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    ¡ê,a	_  ã                   @   s†   d dl mZ d dlZd dlZd dlZd dlZd dlZddgZdd„ Zdd„ Z	ej
jZej
jZe dejejB ¡ZG d	d„ dejƒZdS )
é    ©ÚDecimalNÚFractionÚgcdc                 C   sf   dd l }| dtd¡ t| ƒt  kr2t|ƒkr\n n&|p<| dk rPt | |¡ S t | |¡S t| |ƒS )Nr   z6fractions.gcd() is deprecated. Use math.gcd() instead.é   )ÚwarningsÚwarnÚDeprecationWarningÚtypeÚintÚmathr   Ú_gcd)ÚaÚbr   © r   ú./opt/alt/python38/lib64/python3.8/fractions.pyr      s     ÿ c                 C   s   |r|| |  } }q | S ©Nr   ©r   r   r   r   r   r       s    r   aC  
    \A\s*                      # optional whitespace at the start, then
    (?P<sign>[-+]?)            # an optional sign, then
    (?=\d|\.\d)                # lookahead for digit or .digit
    (?P<num>\d*)               # numerator (possibly empty)
    (?:                        # followed by
       (?:/(?P<denom>\d+))?    # an optional denominator
    |                          # or
       (?:\.(?P<decimal>\d*))? # an optional fractional part
       (?:E(?P<exp>[-+]?\d+))? # and optional exponent
    )
    \s*\Z                      # and optional whitespace to finish
c                       sÊ  e Zd ZdZdQddœ‡ fdd„Zedd	„ ƒZed
d„ ƒZdd„ ZdRdd„Z	e
dd„ ƒZe
dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zeeejƒ\ZZdd„ Zeeejƒ\ZZdd „ Zeeejƒ\ZZd!d"„ Zeeejƒ\ZZ d#d$„ Z!ee!ej"ƒ\Z#Z$d%d&„ Z%ee%e&ƒ\Z'Z(d'd(„ Z)ee)ej*ƒ\Z+Z,d)d*„ Z-d+d,„ Z.d-d.„ Z/d/d0„ Z0d1d2„ Z1d3d4„ Z2d5d6„ Z3d7d8„ Z4dSd9d:„Z5d;d<„ Z6d=d>„ Z7d?d@„ Z8dAdB„ Z9dCdD„ Z:dEdF„ Z;dGdH„ Z<dIdJ„ Z=dKdL„ Z>dMdN„ Z?dOdP„ Z@‡  ZAS )Tr   ©Ú
_numeratorÚ_denominatorr   NT©Ú
_normalizec                   sR  t t| ƒ | ¡}|d k�rdt|ƒtkr6||_d|_|S t|tj	ƒrV|j
|_|j|_|S t|ttfƒrx| ¡ \|_|_|S t|tƒ�rZt |¡}|d kr¢td| ƒ‚t| d¡p°dƒ}| d¡}|rÌt|ƒ}nvd}| d¡}|�rdt|ƒ }|| t|ƒ }||9 }| d¡}	|	�rBt|	ƒ}	|	d	k�r4|d|	 9 }n|d|	  9 }| d
¡dk�rb| }ntdƒ‚nft|ƒt  k�r„t|ƒk�rŠn nn@t|tj	ƒ�rÂt|tj	ƒ�rÂ|j
|j |j
|j  }}ntdƒ‚|d	k�ràtd| ƒ‚|�rBt|ƒt  k�rt|ƒk�r(n nt ||¡}
|d	k �r2|
 }
n
t||ƒ}
||
 }||
 }||_||_|S )Né   z Invalid literal for Fraction: %rZnumÚ0ÚdenomÚdecimalé
   Úexpr   Zsignú-z2argument should be a string or a Rational instancez+both arguments should be Rational instanceszFraction(%s, 0))Úsuperr   Ú__new__r
   r   r   r   Ú
isinstanceÚnumbersÚRationalÚ	numeratorÚdenominatorÚfloatr   Úas_integer_ratioÚstrÚ_RATIONAL_FORMATÚmatchÚ
ValueErrorÚgroupÚlenÚ	TypeErrorÚZeroDivisionErrorr   r   r   )Úclsr%   r&   r   ÚselfÚmr   r   Zscaler   Úg©Ú	__class__r   r   r!   T   sx    

ÿ





$
ÿ

þ
$

zFraction.__new__c                 C   sD   t |tjƒr| |ƒS t |tƒs8td| j|t|ƒjf ƒ‚| | ¡ Ž S )Nz.%s.from_float() only takes floats, not %r (%s))r"   r#   ÚIntegralr'   r/   Ú__name__r
   r(   )r1   Úfr   r   r   Ú
from_floatÁ   s    
ÿzFraction.from_floatc                 C   sV   ddl m} t|tjƒr&|t|ƒƒ}n$t||ƒsJtd| j|t|ƒjf ƒ‚| | 	¡ Ž S )Nr   r   z2%s.from_decimal() only takes Decimals, not %r (%s))
r   r   r"   r#   r7   r   r/   r8   r
   r(   )r1   Zdecr   r   r   r   Úfrom_decimalÏ   s    
ÿÿzFraction.from_decimalc                 C   s   | j | jfS r   r   ©r2   r   r   r   r(   Û   s    zFraction.as_integer_ratioé@B c                 C   sÞ   |dk rt dƒ‚| j|kr"t| ƒS d\}}}}| j| j }}|| }|||  }	|	|krZqŠ|||||  |	f\}}}}||||   }}q<|| | }
t||
|  ||
|  ƒ}t||ƒ}t||  ƒt||  ƒkrÖ|S |S d S )Nr   z$max_denominator should be at least 1)r   r   r   r   )r,   r   r   r   Úabs)r2   Zmax_denominatorZp0Zq0Zp1Zq1ÚnÚdr   Zq2ÚkZbound1Zbound2r   r   r   Úlimit_denominatorã   s$     

zFraction.limit_denominatorc                 C   s   | j S r   )r   ©r   r   r   r   r%     s    zFraction.numeratorc                 C   s   | j S r   )r   rC   r   r   r   r&     s    zFraction.denominatorc                 C   s   d| j j| j| jf S )Nz
%s(%s, %s))r6   r8   r   r   r<   r   r   r   Ú__repr__"  s     ÿzFraction.__repr__c                 C   s(   | j dkrt| jƒS d| j| j f S d S )Nr   z%s/%s)r   r)   r   r<   r   r   r   Ú__str__'  s    

zFraction.__str__c                    sT   ‡ ‡fdd„}dˆ j  d |_ ˆj|_‡ ‡fdd„}dˆ j  d |_ ˆj|_||fS )Nc                    sP   t |ttfƒrˆ| |ƒS t |tƒr0ˆ t| ƒ|ƒS t |tƒrHˆ t| ƒ|ƒS tS d S r   )r"   r   r   r'   ÚcomplexÚNotImplementedr   ©Úfallback_operatorÚmonomorphic_operatorr   r   Úforward~  s    


z-Fraction._operator_fallbacks.<locals>.forwardÚ__c                    sZ   t |tjƒrˆ|| ƒS t |tjƒr4ˆ t|ƒt| ƒƒS t |tjƒrRˆ t|ƒt| ƒƒS tS d S r   )r"   r#   r$   ZRealr'   ÚComplexrF   rG   ©r   r   rH   r   r   ÚreverseŠ  s    
z-Fraction._operator_fallbacks.<locals>.reverseZ__r)r8   Ú__doc__)rJ   rI   rK   rO   r   rH   r   Ú_operator_fallbacks.  s    P	
zFraction._operator_fallbacksc                 C   s,   | j |j  }}t| j| |j|  || ƒS r   ©r&   r   r%   ©r   r   ÚdaÚdbr   r   r   Ú_add™  s    ÿzFraction._addc                 C   s,   | j |j  }}t| j| |j|  || ƒS r   rR   rS   r   r   r   Ú_sub¡  s    ÿzFraction._subc                 C   s   t | j|j | j|j ƒS r   ©r   r%   r&   r   r   r   r   Ú_mul©  s    zFraction._mulc                 C   s   t | j|j | j|j ƒS r   rX   r   r   r   r   Ú_div¯  s    
ÿzFraction._divc                 C   s   | j |j | j|j   S r   ©r%   r&   r   r   r   r   Ú	_floordiv¶  s    zFraction._floordivc                 C   s:   | j |j  }}t| j| ||j ƒ\}}|t||| ƒfS r   )r&   Údivmodr%   r   )r   r   rT   rU   ZdivZn_modr   r   r   Ú_divmod¼  s    zFraction._divmodc                 C   s,   | j |j  }}t| j| |j|  || ƒS r   rR   rS   r   r   r   Ú_modÄ  s    zFraction._modc                 C   s¬   t |tjƒrœ|jdkrŠ|j}|dkr>t| j| | j| dd�S | jdkrft| j|  | j|  dd�S t| j |  | j |  dd�S q¨t| ƒt|ƒ S nt| ƒ| S d S )Nr   r   Fr   )	r"   r#   r$   r&   r%   r   r   r   r'   )r   r   Zpowerr   r   r   Ú__pow__Ë  s&    

þ

þþzFraction.__pow__c                 C   s\   | j dkr| jdkr|| j S t|tjƒr<t|j|jƒ|  S | j dkrP|| j S |t| ƒ S )Nr   r   )	r   r   r"   r#   r$   r   r%   r&   r'   rN   r   r   r   Ú__rpow__é  s    


zFraction.__rpow__c                 C   s   t | j| jdd�S ©NFr   ©r   r   r   rC   r   r   r   Ú__pos__÷  s    zFraction.__pos__c                 C   s   t | j | jdd�S rb   rc   rC   r   r   r   Ú__neg__û  s    zFraction.__neg__c                 C   s   t t| jƒ| jdd�S rb   )r   r>   r   r   rC   r   r   r   Ú__abs__ÿ  s    zFraction.__abs__c                 C   s*   | j dk r| j  | j  S | j | j S d S )Nr   r   rC   r   r   r   Ú	__trunc__  s    
zFraction.__trunc__c                 C   s   | j | j S r   r[   rC   r   r   r   Ú	__floor__
  s    zFraction.__floor__c                 C   s   | j  | j  S r   r[   rC   r   r   r   Ú__ceil__  s    zFraction.__ceil__c                 C   s˜   |d krZt | j| jƒ\}}|d | jk r,|S |d | jkrB|d S |d dkrR|S |d S dt|ƒ }|dkr€tt| | ƒ|ƒS tt| | ƒ| ƒS d S )Nr   r   r   r   )r]   r%   r&   r>   r   Úround)r2   ZndigitsZfloorZ	remainderÚshiftr   r   r   Ú	__round__  s    zFraction.__round__c                 C   sP   t | jtd tƒ}|st}nt| jƒ| t }| dkr:|n| }|dkrLdS |S )Nr   r   éÿÿÿÿéþÿÿÿ)Úpowr   Ú_PyHASH_MODULUSÚ_PyHASH_INFr>   r   )r2   ZdinvZhash_Úresultr   r   r   Ú__hash__,  s    zFraction.__hash__c                 C   sž   t |ƒtkr | j|ko| jdkS t|tjƒrD| j|jkoB| j|jkS t|tj	ƒr`|j
dkr`|j}t|tƒr–t |¡s~t |¡r†d|kS | |  |¡kS ntS d S )Nr   r   ç        )r
   r   r   r   r"   r#   r$   r%   r&   rM   ÚimagÚrealr'   r   ÚisnanÚisinfr:   rG   r   r   r   r   Ú__eq__B  s    
ÿ
zFraction.__eq__c                 C   sh   t |tjƒr&|| j|j | j|j ƒS t |tƒr`t 	|¡sDt 
|¡rN|d|ƒS || |  |¡ƒS ntS d S )Nrt   )r"   r#   r$   r   r&   r   r%   r'   r   rw   rx   r:   rG   )r2   ÚotherÚopr   r   r   Ú_richcmpW  s    
ÿ

zFraction._richcmpc                 C   s   |   |tj¡S r   )r|   ÚoperatorÚltr   r   r   r   Ú__lt__m  s    zFraction.__lt__c                 C   s   |   |tj¡S r   )r|   r}   Úgtr   r   r   r   Ú__gt__q  s    zFraction.__gt__c                 C   s   |   |tj¡S r   )r|   r}   Úler   r   r   r   Ú__le__u  s    zFraction.__le__c                 C   s   |   |tj¡S r   )r|   r}   Úger   r   r   r   Ú__ge__y  s    zFraction.__ge__c                 C   s
   t | jƒS r   )Úboolr   rC   r   r   r   Ú__bool__}  s    zFraction.__bool__c                 C   s   | j t| ƒffS r   )r6   r)   r<   r   r   r   Ú
__reduce__…  s    zFraction.__reduce__c                 C   s    t | ƒtkr| S |  | j| j¡S r   ©r
   r   r6   r   r   r<   r   r   r   Ú__copy__ˆ  s    zFraction.__copy__c                 C   s    t | ƒtkr| S |  | j| j¡S r   r‰   )r2   Zmemor   r   r   Ú__deepcopy__�  s    zFraction.__deepcopy__)r   N)r=   )N)Br8   Ú
__module__Ú__qualname__Ú	__slots__r!   Úclassmethodr:   r;   r(   rB   Úpropertyr%   r&   rD   rE   rQ   rV   r}   ÚaddÚ__add__Ú__radd__rW   ÚsubÚ__sub__Ú__rsub__rY   ÚmulÚ__mul__Ú__rmul__rZ   ÚtruedivÚ__truediv__Ú__rtruediv__r\   ÚfloordivÚ__floordiv__Ú__rfloordiv__r^   r]   Ú
__divmod__Ú__rdivmod__r_   ÚmodÚ__mod__Ú__rmod__r`   ra   rd   re   rf   rg   rh   ri   rl   rs   ry   r|   r   r�   rƒ   r…   r‡   rˆ   rŠ   r‹   Ú__classcell__r   r   r5   r   r   <   sb   m


7

k
)r   r   r   r#   r}   ÚreÚsysÚ__all__r   r   Ú	hash_infoÚmodulusrp   Úinfrq   ÚcompileÚVERBOSEÚ
IGNORECASEr*   r$   r   r   r   r   r   Ú<module>   s   
ô