AlkantarClanX12

Your IP : 18.119.143.45


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/fractions.cpython-35.opt-2.pyc



���]$`�@s�ddlmZddlZddlZddlZddlZddlZddgZdd�Zdd�Z	ej
jZej
j
ZejdejejB�ZGd	d�dej�ZdS)
�)�DecimalN�Fraction�gcdcCs�ddl}|jdtd�t|�tkoBt|�knrz|pP|dkrjtj||�Stj||�St||�S)Nrz6fractions.gcd() is deprecated. Use math.gcd() instead.�)�warnings�warn�DeprecationWarning�type�int�mathr�_gcd)�a�br�r�./opt/alt/python35/lib64/python3.5/fractions.pyrs	
(cCs"x|r|||}}qW|S)Nr)r
rrrrr 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
cs_eZdZdQZddd�fdd�Zedd	��Zed
d��Zdd
d�Ze	dd��Z
e	dd��Zdd�Zdd�Z
dd�Zdd�Zeeej�\ZZdd�Zeeej�\ZZdd�Zeeej�\ZZdd �Zeeej�\ZZd!d"�Z d#d$�Z!d%d&�Z"d'd(�Z#d)d*�Z$d+d,�Z%d-d.�Z&d/d0�Z'd1d2�Z(d3d4�Z)d5d6�Z*d7d8�Z+dd9d:�Z,d;d<�Z-d=d>�Z.d?d@�Z/dAdB�Z0dCdD�Z1dEdF�Z2dGdH�Z3dIdJ�Z4dKdL�Z5dMdN�Z6dOdP�Z7�S)Rr�
_numerator�_denominatorrNTcsUtt|�j|�}|dkr+t|�tkrL||_d|_|St|tj	�rz|j
|_|j|_|St|t�r�tj
|�}|j|_|j|_|St|t�r�tj|�}|j|_|j|_|St|t�rtj|�}|dkr(td|��t|jd�p=d�}|jd�}|rgt|�}n�d}|jd�}|r�dt|�}	||	t|�}||	9}|jd�}
|
r�t|
�}
|
d	kr�|d|
9}n|d|
9}|jd
�dkr(|}q�td��nt|�tkoNt|�knrVnTt|tj	�r�t|tj	�r�|j
|j|j
|j}}ntd
��|d	kr�td|��|r?t|�tko�t|�knrtj||�}|d	kr+|}nt||�}||}||}||_||_|S)N�z Invalid literal for Fraction: %r�num�0�denom�decimal�
�expr�sign�-z2argument should be a string or a Rational instancez+both arguments should be Rational instanceszFraction(%s, 0))�superr�__new__r	r
rr�
isinstance�numbers�Rational�	numerator�denominator�float�
from_floatr�from_decimal�str�_RATIONAL_FORMAT�match�
ValueError�group�len�	TypeError�ZeroDivisionErrorrrr)�clsr!r"�
_normalize�self�value�mrrZscaler�g)�	__class__rrrTs�		


(
(


		zFraction.__new__cCs�t|tj�r||�St|t�sPtd|j|t|�jf��tj|�rxt	d||jf��tj
|�r�td||jf��||j��S)Nz.%s.from_float() only takes floats, not %r (%s)zCannot convert %r to %s.)
rr�Integralr#r,�__name__r	r�isnanr)�isinf�
OverflowError�as_integer_ratio)r.�frrrr$�s
zFraction.from_floatcCs)ddlm}t|tj�r7|t|��}n4t||�sktd|j|t|�jf��|j	�r�t
d||jf��|j�r�td||jf��|j
�\}}}tdjtt|���}|r�|}|dkr||d|�S||d|�SdS)Nr)rz2%s.from_decimal() only takes Decimals, not %r (%s)zCannot convert %s to %s.�r)rrrrr5r
r,r6r	Zis_infiniter9Zis_nanr)Zas_tuple�join�mapr&)r.Zdecrr�digitsrrrrr%�s&zFraction.from_decimali@Bc
Cs%|dkrtd��|j|kr1t|�Sd\}}}}|j|j}}xd||}|||}	|	|kr~P||||||	f\}}}}||||}}qYW|||}
t||
|||
|�}t||�}t||�t||�kr|S|SdS)Nrz$max_denominator should be at least 1r)rrrr)r)rrr�abs)
r0Zmax_denominatorZp0Zq0Zp1Zq1�n�dr
Zq2�kZbound1Zbound2rrr�limit_denominator�s& 

& zFraction.limit_denominatorcCs|jS)N)r)r
rrrr!*szFraction.numeratorcCs|jS)N)r)r
rrrr".szFraction.denominatorcCsd|jj|j|jfS)Nz
%s(%s, %s))r4r6rr)r0rrr�__repr__2szFraction.__repr__cCs4|jdkrt|j�Sd|j|jfSdS)Nrz%s/%s)rr&r)r0rrr�__str__7s
zFraction.__str__cst��fdd�}d�jd|_�j|_��fdd�}d�jd|_�j|_||fS)Ncsnt|ttf�r"�||�St|t�rD�t|�|�St|t�rf�t|�|�StSdS)N)rr
rr#�complex�NotImplemented)r
r)�fallback_operator�monomorphic_operatorrr�forward�s
z-Fraction._operator_fallbacks.<locals>.forward�__cs}t|tj�r�||�St|tj�rJ�t|�t|��St|tj�ru�t|�t|��StSdS)N)rrr ZRealr#�ComplexrGrH)rr
)rIrJrr�reverse�s
z-Fraction._operator_fallbacks.<locals>.reverseZ__r)r6�__doc__)rJrIrKrNr)rIrJr�_operator_fallbacks>sP	
zFraction._operator_fallbackscCs6|j|j}}t|j||j|||�S)N)r"rr!)r
r�da�dbrrr�_add�sz
Fraction._addcCs6|j|j}}t|j||j|||�S)N)r"rr!)r
rrQrRrrr�_sub�sz
Fraction._subcCs!t|j|j|j|j�S)N)rr!r")r
rrrr�_mul�sz
Fraction._mulcCs!t|j|j|j|j�S)N)rr!r")r
rrrr�_div�sz
Fraction._divcCstj||�S)N)r�floor)r
rrrr�__floordiv__�szFraction.__floordiv__cCstj||�S)N)rrW)rr
rrr�
__rfloordiv__�szFraction.__rfloordiv__cCs||}|||S)Nr)r
r�divrrr�__mod__�s
zFraction.__mod__cCs||}|||S)Nr)rr
rZrrr�__rmod__�s
zFraction.__rmod__cCs�t|tj�r�|jdkr�|j}|dkrWt|j||j|dd�S|jdkr�t|j||j|dd�St|j||j|dd�Sq�t|�t|�Snt|�|SdS)Nrrr/F)	rrr r"r!rrrr#)r
rZpowerrrr�__pow__�s 	


zFraction.__pow__cCsz|jdkr)|jdkr)||jSt|tj�rRt|j|j�|S|jdkrl||jS|t|�S)Nrr)	rrrrr rr!r"r#)rr
rrr�__rpow__�szFraction.__rpow__cCst|j|jdd�S)Nr/F)rrr)r
rrr�__pos__szFraction.__pos__cCst|j|jdd�S)Nr/F)rrr)r
rrr�__neg__szFraction.__neg__cCstt|j�|jdd�S)Nr/F)rr@rr)r
rrr�__abs__szFraction.__abs__cCs1|jdkr|j|jS|j|jSdS)Nr)rr)r
rrr�	__trunc__szFraction.__trunc__cCs|j|jS)N)r!r")r
rrr�	__floor__szFraction.__floor__cCs|j|jS)N)r!r")r
rrr�__ceil__szFraction.__ceil__cCs�|dkrut|j|j�\}}|d|jkr>|S|d|jkrY|dS|ddkrm|S|dSdt|�}|dkr�tt||�|�Stt||�|�SdS)Nrrrr)�divmodr!r"r@r�round)r0ZndigitsrWZ	remainderZshiftrrr�	__round__ szFraction.__round__cCslt|jtdt�}|s(t}nt|j�|t}|dkrQ|n|}|dkrhdS|S)Nrrr������)�powr�_PyHASH_MODULUS�_PyHASH_INFr@r)r0ZdinvZhash_�resultrrr�__hash__9s	zFraction.__hash__cCs�t|�tkr.|j|ko-|jdkSt|tj�rb|j|jkoa|j|jkSt|tj	�r�|j
dkr�|j}t|t�r�t
j|�s�t
j|�r�d|kS||j|�kSntSdS)Nrrg)r	r
rrrrr r!r"rM�imag�realr#rr7r8r$rH)r
rrrr�__eq__Os!	
zFraction.__eq__cCs�t|tj�r3||j|j|j|j�St|t�r�tj	|�s`tj
|�rm|d|�S|||j|��SntSdS)Ng)
rrr rr"rr!r#rr7r8r$rH)r0�other�oprrr�_richcmpds
zFraction._richcmpcCs|j|tj�S)N)rt�operator�lt)r
rrrr�__lt__zszFraction.__lt__cCs|j|tj�S)N)rtru�gt)r
rrrr�__gt__~szFraction.__gt__cCs|j|tj�S)N)rtru�le)r
rrrr�__le__�szFraction.__le__cCs|j|tj�S)N)rtru�ge)r
rrrr�__ge__�szFraction.__ge__cCs
|jdkS)Nr)r)r
rrr�__bool__�szFraction.__bool__cCs|jt|�ffS)N)r4r&)r0rrr�
__reduce__�szFraction.__reduce__cCs,t|�tkr|S|j|j|j�S)N)r	rr4rr)r0rrr�__copy__�szFraction.__copy__cCs,t|�tkr|S|j|j|j�S)N)r	rr4rr)r0�memorrr�__deepcopy__�szFraction.__deepcopy__)rr)8r6�
__module__�__qualname__�	__slots__r�classmethodr$r%rD�propertyr!r"rErFrPrSru�add�__add__�__radd__rT�sub�__sub__�__rsub__rU�mul�__mul__�__rmul__rV�truediv�__truediv__�__rtruediv__rXrYr[r\r]r^r_r`rarbrcrdrgrnrqrtrwryr{r}r~rr�r�rr)r4rr<sTu7k)rrrrru�re�sys�__all__rr�	hash_info�modulusrk�infrl�compile�VERBOSE�
IGNORECASEr'r rrrrr�<module>s