grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026U iÛf _ã@s†ddlmZddlZddlZddlZddlZddlZddgZdd„Zdd„Z ej j Z ej j Ze dejejB¡ZGd d„dejƒZdS) é©ÚDecimalNÚFractionÚgcdcCsfddl}| dtd¡t|ƒtkr2t|ƒkr\nn&|p<|dkrPt ||¡ St ||¡St||ƒS)Nrz6fractions.gcd() is deprecated. Use math.gcd() instead.é)ÚwarningsÚwarnÚDeprecationWarningÚtypeÚintÚmathrÚ_gcd)ÚaÚbr©rú./opt/alt/python38/lib64/python3.8/fractions.pyrsÿ   cCs|r|||}}q|S©Nr©rrrrrr sr aC \A\s* # optional whitespace at the start, then (?P[-+]?) # an optional sign, then (?=\d|\.\d) # lookahead for digit or .digit (?P\d*) # numerator (possibly empty) (?: # followed by (?:/(?P\d+))? # an optional denominator | # or (?:\.(?P\d*))? # an optional fractional part (?:E(?P[-+]?\d+))? # and optional exponent ) \s*\Z # and optional whitespace to finish csÊeZdZdZdQddœ‡fdd„ Zedd „ƒZed d „ƒZd d „ZdRdd„Z e dd„ƒZ e dd„ƒZ dd„Z dd„Zdd„Zdd„Zeeejƒ\ZZdd„Zeeejƒ\ZZdd „Zeeejƒ\ZZd!d"„Zeeejƒ\ZZ d#d$„Z!ee!ej"ƒ\Z#Z$d%d&„Z%ee%e&ƒ\Z'Z(d'd(„Z)ee)ej*ƒ\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„ZdMdN„Z?dOdP„Z@‡ZAS)Tr©Ú _numeratorÚ _denominatorrNT©Ú _normalizec sRtt|ƒ |¡}|dk�rdt|ƒtkr6||_d|_|St|tj ƒrV|j |_|j |_|St|t t fƒrx| ¡\|_|_|St|tƒ�rZt |¡}|dkr¢td|ƒ‚t| d¡p°dƒ}| d¡}|rÌt|ƒ}nvd}| d¡}|�rdt|ƒ}||t|ƒ}||9}| d¡} | �rBt| ƒ} | d k�r4|d| 9}n|d| 9}| d ¡d k�rb| }ntd ƒ‚nft|ƒtk�r„t|ƒk�rŠnnn@t|tj ƒ�rÂt|tj ƒ�rÂ|j |j |j |j }}ntd ƒ‚|d k�ràtd|ƒ‚|�rBt|ƒtk�rt|ƒk�r(nnt ||¡} |d k�r2| } n t||ƒ} || }|| }||_||_|S)Néz Invalid literal for Fraction: %rZnumÚ0ÚdenomÚdecimalé ÚexprZsignú-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ÚfloatrÚas_integer_ratioÚstrÚ_RATIONAL_FORMATÚmatchÚ ValueErrorÚgroupÚlenÚ TypeErrorÚZeroDivisionErrorr rr ) Úclsr%r&rÚselfÚmrrZscalerÚg©Ú __class__rrr!Tsx     ÿ       $ ÿ  þ  $   zFraction.__new__cCsDt|tjƒr||ƒSt|tƒs8td|j|t|ƒjfƒ‚|| ¡ŽS)Nz.%s.from_float() only takes floats, not %r (%s))r"r#ÚIntegralr'r/Ú__name__r r()r1ÚfrrrÚ from_floatÁs  ÿzFraction.from_floatcCsVddlm}t|tjƒr&|t|ƒƒ}n$t||ƒsJtd|j|t|ƒjfƒ‚||  ¡ŽS)Nrrz2%s.from_decimal() only takes Decimals, not %r (%s)) rrr"r#r7r r/r8r r()r1ZdecrrrrÚ from_decimalÏs   ÿÿzFraction.from_decimalcCs |j|jfSrr©r2rrrr(ÛszFraction.as_integer_ratioé@Bc CsÞ|dkrtdƒ‚|j|kr"t|ƒSd\}}}}|j|j}}||}|||} | |krZqŠ|||||| f\}}}}||||}}q<|||} t|| ||| |ƒ} t||ƒ} t| |ƒt| |ƒkrÖ| S| SdS)Nrz$max_denominator should be at least 1)rrrr)r,rrrÚabs) r2Zmax_denominatorZp0Zq0Zp1Zq1ÚnÚdrZq2ÚkZbound1Zbound2rrrÚlimit_denominatorãs$      zFraction.limit_denominatorcCs|jSr)r©rrrrr%szFraction.numeratorcCs|jSr)rrCrrrr&szFraction.denominatorcCsd|jj|j|jfS)Nz %s(%s, %s))r6r8rrr<rrrÚ__repr__"sÿzFraction.__repr__cCs(|jdkrt|jƒSd|j|jfSdS)Nrz%s/%s)rr)rr<rrrÚ__str__'s  zFraction.__str__csT‡‡fdd„}dˆjd|_ˆj|_‡‡fdd„}dˆjd|_ˆj|_||fS)NcsPt|ttfƒrˆ||ƒSt|tƒr0ˆt|ƒ|ƒSt|tƒrHˆt|ƒ|ƒStSdSr)r"r rr'ÚcomplexÚNotImplementedr©Úfallback_operatorÚmonomorphic_operatorrrÚforward~s   z-Fraction._operator_fallbacks..forwardÚ__csZt|tjƒrˆ||ƒSt|tjƒr4ˆt|ƒt|ƒƒSt|tjƒrRˆt|ƒt|ƒƒStSdSr)r"r#r$ZRealr'ÚComplexrFrG©rrrHrrÚreverseŠs    z-Fraction._operator_fallbacks..reverseZ__r)r8Ú__doc__)rJrIrKrOrrHrÚ_operator_fallbacks.sP  zFraction._operator_fallbackscCs,|j|j}}t|j||j|||ƒSr©r&rr%©rrÚdaÚdbrrrÚ_add™sÿz Fraction._addcCs,|j|j}}t|j||j|||ƒSrrRrSrrrÚ_sub¡sÿz Fraction._subcCst|j|j|j|jƒSr©rr%r&rrrrÚ_mul©sz Fraction._mulcCst|j|j|j|jƒSrrXrrrrÚ_div¯s  ÿz Fraction._divcCs|j|j|j|jSr©r%r&rrrrÚ _floordiv¶szFraction._floordivcCs:|j|j}}t|j|||jƒ\}}|t|||ƒfSr)r&Údivmodr%r)rrrTrUZdivZn_modrrrÚ_divmod¼szFraction._divmodcCs,|j|j}}t|j||j|||ƒSrrRrSrrrÚ_modÄsz Fraction._modcCs¬t|tjƒrœ|jdkrŠ|j}|dkr>t|j||j|dd�S|jdkrft|j| |j| dd�St|j | |j | dd�Sq¨t|ƒt|ƒSn t|ƒ|SdS)NrrFr) r"r#r$r&r%rrrr')rrZpowerrrrÚ__pow__Ës&   þ   þ þzFraction.__pow__cCs\|jdkr|jdkr||jSt|tjƒrrrrCrrrÚ__abs__ÿszFraction.__abs__cCs*|jdkr|j |j S|j|jSdS)NrrrCrrrÚ __trunc__s zFraction.__trunc__cCs |j|jSrr[rCrrrÚ __floor__ szFraction.__floor__cCs|j |j Srr[rCrrrÚ__ceil__szFraction.__ceil__cCs˜|dkrZt|j|jƒ\}}|d|jkr,|S|d|jkrB|dS|ddkrR|S|dSdt|ƒ}|dkr€tt||ƒ|ƒStt||ƒ|ƒSdS)Nrrrr)r]r%r&r>rÚround)r2ZndigitsZfloorZ remainderÚshiftrrrÚ __round__s  zFraction.__round__cCsPt|jtdtƒ}|st}nt|jƒ|t}|dkr:|n| }|dkrLdS|S)Nrréÿÿÿÿéþÿÿÿ)ÚpowrÚ_PyHASH_MODULUSÚ _PyHASH_INFr>r)r2ZdinvZhash_ÚresultrrrÚ__hash__,s zFraction.__hash__cCsžt|ƒtkr |j|ko|jdkSt|tjƒrD|j|jkoB|j|jkSt|tj ƒr`|j dkr`|j }t|t ƒr–t  |¡s~t  |¡r†d|kS|| |¡kSntSdS)Nrrç)r r rrr"r#r$r%r&rMÚimagÚrealr'r ÚisnanÚisinfr:rGrrrrÚ__eq__Bs    ÿ zFraction.__eq__cCsht|tjƒr&||j|j|j|jƒSt|tƒr`t  |¡sDt  |¡rN|d|ƒS|||  |¡ƒSnt SdS)Nrt) r"r#r$rr&rr%r'r rwrxr:rG)r2ÚotherÚoprrrÚ_richcmpWs   ÿ  zFraction._richcmpcCs| |tj¡Sr)r|ÚoperatorÚltrrrrÚ__lt__mszFraction.__lt__cCs| |tj¡Sr)r|r}ÚgtrrrrÚ__gt__qszFraction.__gt__cCs| |tj¡Sr)r|r}ÚlerrrrÚ__le__uszFraction.__le__cCs| |tj¡Sr)r|r}ÚgerrrrÚ__ge__yszFraction.__ge__cCs t|jƒSr)ÚboolrrCrrrÚ__bool__}szFraction.__bool__cCs|jt|ƒffSr)r6r)r<rrrÚ __reduce__…szFraction.__reduce__cCs t|ƒtkr|S| |j|j¡Sr©r rr6rrr<rrrÚ__copy__ˆs zFraction.__copy__cCs t|ƒtkr|S| |j|j¡Srr‰)r2ZmemorrrÚ __deepcopy__�s zFraction.__deepcopy__)rN)r=)N)Br8Ú __module__Ú __qualname__Ú __slots__r!Ú classmethodr:r;r(rBÚpropertyr%r&rDrErQrVr}Ú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`rardrerfrgrhrirlrsryr|rr�rƒr…r‡rˆrŠr‹Ú __classcell__rrr5rr<sbm   7  k )rrr r#r}ÚreÚsysÚ__all__rr Ú hash_infoÚmodulusrpÚinfrqÚcompileÚVERBOSEÚ IGNORECASEr*r$rrrrrÚs  ô