0 $ˆl–äY>” je¶…8 Cq§nµ1h߯ „ ÀiÿÅÂÉ?÷a ´i_ã@sxdZddlmZddlZddlZddlZddlZddlZdgZej j Z ej j Z e dejejB¡ZGdd„dejƒZdS)z+Fraction, infinite-precision, real numbers.é©ÚDecimalNÚFractionaC \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ÎeZdZdZdZdRddœ‡fdd„ Zed d „ƒZed d „ƒZd d„Z dSdd„Z e dd„ƒZ e dd„ƒZ dd„Zdd„Zdd„Zdd„Zeeejƒ\ZZdd„Zeeejƒ\ZZd d!„Zeeejƒ\ZZd"d#„Zeeejƒ\Z Z!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/„Z0d0d1„Z1d2d3„Z2d4d5„Z3d6d7„Z4d8d9„Z5dTd:d;„Z6dd?„Z8d@dA„Z9dBdC„Z:dDdE„Z;dFdG„ZdLdM„Z?dNdO„Z@dPdQ„ZA‡ZBS)Ura]This class implements rational numbers. In the two-argument form of the constructor, Fraction(8, 6) will produce a rational number equivalent to 4/3. Both arguments must be Rational. The numerator defaults to 0 and the denominator defaults to 1 so that Fraction(3) == 3 and Fraction() == 0. Fractions can also be constructed from: - numeric strings similar to those accepted by the float constructor (for example, '-2.3' or '1e10') - strings of the form '123/456' - float and Decimal instances - other Rational instances (including integers) ©Ú _numeratorÚ _denominatorrNT©Ú _normalizec s"tt|ƒ |¡}|du�rdt|ƒtur6||_d|_|St|tj ƒrV|j |_|j |_|St|t t fƒrx| ¡\|_|_|St|tƒ�rZt |¡}|dur¢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|ƒtu�r„t|ƒu�rŠnnn@t|tj ƒ�rÂt|tj ƒ�rÂ|j |j |j |j }}ntdƒ‚|d k�ràtd|ƒ‚|�rt ||¡} |d k�r| } || }|| }||_||_|S)a£Constructs a Rational. Takes a string like '3/2' or '1.5', another Rational instance, a numerator/denominator pair, or a float. Examples -------- >>> Fraction(10, -8) Fraction(-5, 4) >>> Fraction(Fraction(1, 7), 5) Fraction(1, 35) >>> Fraction(Fraction(1, 7), Fraction(2, 3)) Fraction(3, 14) >>> Fraction('314') Fraction(314, 1) >>> Fraction('-35/4') Fraction(-35, 4) >>> Fraction('3.1415') # conversion from numeric string Fraction(6283, 2000) >>> Fraction('-47e-2') # string may include a decimal exponent Fraction(-47, 100) >>> Fraction(1.47) # direct construction from float (exact conversion) Fraction(6620291452234629, 4503599627370496) >>> Fraction(2.25) Fraction(9, 4) >>> Fraction(Decimal('1.47')) Fraction(147, 100) 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__ÚtypeÚintrrÚ isinstanceÚnumbersÚRationalÚ numeratorÚ denominatorÚfloatrÚas_integer_ratioÚstrÚ_RATIONAL_FORMATÚmatchÚ ValueErrorÚgroupÚlenÚ TypeErrorÚZeroDivisionErrorÚmathÚgcd) Úclsrrr ÚselfÚmr rZscalerÚg©Ú __class__©ú!/usr/lib64/python3.9/fractions.pyr>st