????
Your IP : 3.142.201.19
�
���G�vH����dZddlmZddlZddlZddlZddlZddlZddlZdgZ ejjZejjZejd��d��Zej"dej$ej&z�Zd
d �Zd
�Zej"dej.ej$z�j0ZGd�dej4�Zy)z/Fraction, infinite-precision, rational numbers.���DecimalN�Fractioni@)�maxsizec�� t|dt�}ttt|��|z�}|dk\r|n|}|dk(rdS|S#t$r t
}Y�$wxYw)N���r���)�pow�_PyHASH_MODULUS�hash�abs�
ValueError�_PyHASH_INF)� numerator�denominator�dinv�hash_�results �0/opt/alt/python312/lib64/python3.12/fractions.py�_hash_algorithmrse��2��;��O�4��(�T�#�i�.�)�D�0�1���1�n�U�5�&�F��2��2�)�6�)��+�����s�A�A�Aa�
\A\s* # optional whitespace at the start,
(?P<sign>[-+]?) # an optional sign, then
(?=\d|\.\d) # lookahead for digit or .digit
(?P<num>\d*|\d+(_\d+)*) # numerator (possibly empty)
(?: # followed by
(?:\s*/\s*(?P<denom>\d+(_\d+)*))? # an optional denominator
| # or
(?:\.(?P<decimal>\d*|\d+(_\d+)*))? # an optional fractional part
(?:E(?P<exp>[-+]?\d+(_\d+)*))? # and optional exponent
)
\s*\Z # and optional whitespace to finish
c��|dk\r |d|zz}n |d|zz}t||dz z|�\}}|dk(r
|dzdk(r|dz}|r|dkn|dk}|t|�fS)aMRound a rational number to the nearest multiple of a given power of 10.
Rounds the rational number n/d to the nearest integer multiple of
10**exponent, rounding to the nearest even integer multiple in the case of
a tie. Returns a pair (sign: bool, significand: int) representing the
rounded value (-1)**sign * significand * 10**exponent.
If no_neg_zero is true, then the returned sign will always be False when
the significand is zero. Otherwise, the sign reflects the sign of the
input.
d must be positive, but n and d need not be relatively prime.
r�
�r )�divmodr
)�n�d�exponent�no_neg_zero�q�r�signs r�_round_to_exponentr"Js|���1�}� �R��\��� �R�(��]����!�q�A�v�,��"�D�A�q��A�v�!�a�%�1�*� �R����1�q�5�Q��U�D���Q��<��c��|dk(rddd|z
fStt|��t|�}}t|�t|�z
||kz}||z
}t|||�\}}tt|��|dzk(r
|dz}|dz
}|||fS)a�Round a rational number to a given number of significant figures.
Rounds the rational number n/d to the given number of significant figures
using the round-ties-to-even rule, and returns a triple
(sign: bool, significand: int, exponent: int) representing the rounded
value (-1)**sign * significand * 10**exponent.
In the special case where n = 0, returns a significand of zero and
an exponent of 1 - figures, for compatibility with formatting.
Otherwise, the returned significand satisfies
10**(figures - 1) <= significand < 10**figures.
d must be positive, but n and d need not be relatively prime.
figures must be positive.
rFrr)�strr
�lenr") rr�figures�str_n�str_d�mrr!�significands r�_round_to_figuresr,gs���" �A�v��a��W��$�$��s�1�v�;��A��5�E��E�
�S��Z��5�E�>�2�A��7�{�H�*�1�a��:��D�+��3�{����!��+������A�
����h�&�&r#a�
(?:
(?P<fill>.)?
(?P<align>[<>=^])
)?
(?P<sign>[-+ ]?)
(?P<no_neg_zero>z)?
(?P<alt>\#)?
# A '0' that's *not* followed by another digit is parsed as a minimum width
# rather than a zeropad flag.
(?P<zeropad>0(?=[0-9]))?
(?P<minimumwidth>0|[1-9][0-9]*)?
(?P<thousands_sep>[,_])?
(?:\.(?P<precision>0|[1-9][0-9]*))?
(?P<presentation_type>[eEfFgG%])
c���eZdZdZdZd,�fd� Zed��Zed��Ze�fd��Z d�Z
d�Zd-d �Ze
d
��Ze
d��Zd�Zd
�Zd�Zd�Zd�Zeeej,�\ZZd�Zeeej4�\ZZd�Zeeej<�\ZZ d�Z!ee!ejD�\Z#Z$d�Z%ee%ejL�\Z'Z(d�Z)ee)e*�\Z+Z,d�Z-ee-ej\�\Z/Z0d�Z1d�Z2d�Z3d�Z4d�Z5ejlfd�Z7d�Z8d�Z9d�Z:d.d �Z;d!�Z<d"�Z=d#�Z>d$�Z?d%�Z@d&�ZAd'�ZBd(�ZCd)�ZDd*�ZEd+�ZF�xZGS)/ra]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�_denominatorc�B��tt|�|�}|���t|�tur||_d|_|St|tj�r$|j|_|j|_|St|ttf�r|j�\|_|_|St|t�r�t j#|�}|�t%d|z��t |j'd�xsd�}|j'd�}|rt |�}n�d}|j'd�}|r6|j)dd�}d t+|�z}||zt |�z}||z}|j'd
�}|r"t |�}|dk\r |d |zz}n |d |zz}|j'd�d
k(r�|}n�t-d��t|�tcxur
t|�urnnnrt|tj�rMt|tj�r3|j|jz|j|jz}}nt-d��|dk(rt/d|z��t1j2||�} |dkr| } || z}|| z}||_||_|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)
rz Invalid literal for Fraction: %r�num�0�denom�decimal�_�r�exprr!�-z2argument should be a string or a Rational instancez+both arguments should be Rational instances�Fraction(%s, 0))�superr�__new__�type�intr/r0�
isinstance�numbers�Rationalrr�floatr�as_integer_ratior%�_RATIONAL_FORMAT�matchr�group�replacer&� TypeError�ZeroDivisionError�math�gcd)�clsrr�selfr*r4r5�scaler8�g� __class__s �rr<zFraction.__new__�s����>�X�s�+�C�0�����I��#�%�"+���$%��!����I�w�'7�'7�8�"+�"5�"5���$-�$9�$9��!����I��w�'7�8�5>�5O�5O�5Q�2����!2����I�s�+�$�*�*�9�5���9�$�%G�%.�&/�0�0������� 5�#�6� �����(���"%�e�*�K�"#�K��g�g�i�0�G��")�/�/�#�r�":�� "�C��L� 0��$-��$5��G��$D� �#�u�,���'�'�%�.�C��!�#�h���!�8�%��S��0�I�'�2��t�8�3�K��7�7�6�?�c�)�!*�
�I� �!9�:�:��)�_��
8�t�K�'8�
8����G�$4�$4�5��{�G�$4�$4�5��#�#�k�&=�&=�=��%�%� �(=�(=�=�#�I�
�1�2�
2��!��#�$5� �$A�B�B��H�H�Y��,����?���A��a�� �����#���'����r#c ��t|tj�r||�St|t�s1t |j
�d|�dt
|�j
�d���|j|j��S)z�Converts a finite float to a rational number, exactly.
Beware that Fraction.from_float(0.3) != Fraction(3, 10).
z%.from_float() only takes floats, not � (�)) r?r@�IntegralrBrH�__name__r=�_from_coprime_intsrC)rL�fs r�
from_floatzFraction.from_float#sm���a��)�)�*��q�6�M��A�u�%�� �\�\�1�d�1�g�.>�.>�@�A�
A�%�s�%�%�q�'9�'9�';�<�<r#c ��ddlm}t|tj�r|t|��}n=t||�s1t
|j�d|�dt|�j�d���|j|j��S)zAConverts a finite Decimal instance to a rational number, exactly.rrz).from_decimal() only takes Decimals, not rRrS)r5rr?r@rTr>rHrUr=rVrC)rL�decrs r�from_decimalzFraction.from_decimal1st�� $��c�7�+�+�,��#�c�(�#�C��C��)�����s�D��I�$6�$6�8�9�
9�&�s�%�%�s�';�';�'=�>�>r#c�J��tt|�|�}||_||_|S)z�Convert a pair of ints to a rational number, for internal use.
The ratio of integers should be in lowest terms and the denominator
should be positive.
)r;rr<r/r0)rLrr�objrPs �rrVzFraction._from_coprime_ints=s*����H�c�*�3�/��"���&����
r#c� �|jdk(S)z*Return True if the Fraction is an integer.r�r0�rMs r�
is_integerzFraction.is_integerIs��� � �A�%�%r#c�2�|j|jfS)z�Return a pair of integers, whose ratio is equal to the original Fraction.
The ratio is in lowest terms and has a positive denominator.
r.r`s rrCzFraction.as_integer_ratioMs��
����!2�!2�3�3r#c��|dkrtd��|j|krt|�Sd\}}}}|j|j}} ||z}|||zz} | |kDrn|||||zz| f\}}}}||||zz
}}�/||z
|z}
d|z||
|zzz|jkrtj ||�Stj ||
|zz||
|zz�S)aWClosest Fraction to self with denominator at most max_denominator.
>>> Fraction('3.141592653589793').limit_denominator(10)
Fraction(22, 7)
>>> Fraction('3.141592653589793').limit_denominator(100)
Fraction(311, 99)
>>> Fraction(4321, 8765).limit_denominator(10000)
Fraction(4321, 8765)
rz$max_denominator should be at least 1)rrrr�)rr0rr/rV)rM�max_denominator�p0�q0�p1�q1rr�a�q2�ks r�limit_denominatorzFraction.limit_denominatorTs��@�Q���C�D�D�����/��D�>�!�#���B��B����� 1� 1�1����1��A��A�b�D��B��O�#����R��"��W�b�0�N�B��B���a��!��e�q�A�
��R�
�"�$��
�Q�3��1�R�4��=�D�-�-�-��.�.�r�2�6�6��.�.�r�!�B�$�w��1�R�4��@�@r#c��|jS�N)r/�rjs rrzFraction.numerator�s���|�|�r#c��|jSror_rps rrzFraction.denominator�s���~�~�r#c�h�|jj�d|j�d|j�d�S)z
repr(self)�(z, rS)rPrUr/r0r`s r�__repr__zFraction.__repr__�s*��#�~�~�6�6�#����0A�0A�C� Cr#c��|jdk(rt|j�S|j�d|j��S)z str(self)r�/)r0r%r/r`s r�__str__zFraction.__str__�s4������!��t���'�'�"�o�o�t�/@�/@�A�Ar#c
��� �!�|st|�St|�}|�$td|�dt|�j����|d�*|d�%td|�dt|�j�d���|dxsd}|dxsd }|d
dk(rdn|d
}t|d
�}t|d�}t|d�}t
|dxsd�} |d�!t
|dxsd�}
|d}|dvxr|}|}
|dvrdnd}|dvr7|
}|dk(r|dz}t|j|j||�\}}d}|
}nY|dvrt|
d�n|
dz}t|j|j|�\}}}|dvxs|dkDxs||zd k}|r|dz
n|}|dk(rd}n|r|�||zd!��}nd}|d|dz�d"��}|rdn|}|dt|�|z
� |t|�|z
d}|r|jd�}|
r|sdnd#}||z|z}|r8| t|�z
t|�z
}� j�!rd$|zd%zdzn|�� �!rIdt� �dz
d$zz}� d|dj� �!fd&�t!|t� �d$�D��z� � |z}|| t|�z
t|�z
z}|d k(r||z|zS|d'k(r||z|zS|d(k(rt|�dz}|d||z|z||dzS||z|zS))zAFormat this fraction according to the given format specification.NzInvalid format specifier z for object of type �align�zeropadz0; can't use explicit alignment when zero-padding�fill� �>r!r9r7r�alt�minimumwidthr3�
thousands_sep� precision�6�presentation_type�gG�EFG�E�ezfF%�%rdFr�eEr���z+03dr�.��c3�4�K�|]}��||dzz���y�w)r�N�)�.0�pos�leadingr�s ��r� <genexpr>z&Fraction.__format__.<locals>.<genexpr>s)�����4�<�C����c�A�g� 6�6�<�s��<�^)r%�#_FLOAT_FORMAT_SPECIFICATION_MATCHERrr=rU�boolr>r"r/r0�maxr,r&�rstrip�zfill�join�range)"rM�format_specrEr{ry�pos_signr�alternate_formrzrr�r��
trim_zeros�
trim_point�exponent_indicatorr�negativer+�
scientific� point_posr'�suffix�digitsr!� frac_part� separator�trailing�min_leading� first_pos�body�padding�halfr�r�s" @@r�
__format__zFraction.__format__�s�����t�9��4�K�@���=��+�K�?�;&�&*�4�j�&9�&9�%<�>��
��7�^�
'�E�)�,<�,H��+�K�?�;&�&*�4�j�&9�&9�%<�=A�A��
�
�V�}�#����g��%�#���v��#�-�2�5��=���5��/�0���e�E�l�+���u�Y�'�(���5��0�7�C�8���o�.�
���k�*�1�c�2� �!�"5�6��&�$�.�E�~�3E�
�'�'�
�$5��$>�S�C����%�!�z�H� �C�'��A�
��$6�����!2�!2�H�k�%K�!�H�k��J�!�I�%��,��I�q�!���]�
�
/@�����!2�!2�G�/=�+�H�k�8�"�T�)�,��a�<�,��g�%��+�
�
(2��!���y�I���#��F�
�*�+�H�y�,@��+F�G�F��F� ��)�a�-���1�2��
�s�H���2�3�v�;��2�3���3�v�;��2�4�5� ��!�(�(��-�I�$�Y�B�C� ��y�(�6�1���&��T��2�S��]�B�K��m�m�,9��K��1�$�q�(�{��G�
��S��\�A�-��2�2�I��j�y�)�B�G�G�4� ��C��L�!�<�4�-��G���!���,��T��2�S��Y�>�?���C�<��T�>�D�(�(�
�c�\��$�;��(�(�
�c�\��w�<�1�$�D��5�D�>�D�(�4�/�'�$�%�.�@�@��'�>�D�(�(r#c�������fd�}d�jzdz|_�j|_��fd�}d�jzdz|_�j|_||fS)a�Generates forward and reverse operators given a purely-rational
operator and a function from the operator module.
Use this like:
__op__, __rop__ = _operator_fallbacks(just_rational_op, operator.op)
In general, we want to implement the arithmetic operations so
that mixed-mode operations either call an implementation whose
author knew about the types of both arguments, or convert both
to the nearest built in type and do the operation there. In
Fraction, that means that we define __add__ and __radd__ as:
def __add__(self, other):
# Both types have numerators/denominator attributes,
# so do the operation directly
if isinstance(other, (int, Fraction)):
return Fraction(self.numerator * other.denominator +
other.numerator * self.denominator,
self.denominator * other.denominator)
# float and complex don't have those operations, but we
# know about those types, so special case them.
elif isinstance(other, float):
return float(self) + other
elif isinstance(other, complex):
return complex(self) + other
# Let the other type take over.
return NotImplemented
def __radd__(self, other):
# radd handles more types than add because there's
# nothing left to fall back to.
if isinstance(other, numbers.Rational):
return Fraction(self.numerator * other.denominator +
other.numerator * self.denominator,
self.denominator * other.denominator)
elif isinstance(other, Real):
return float(other) + float(self)
elif isinstance(other, Complex):
return complex(other) + complex(self)
return NotImplemented
There are 5 different cases for a mixed-type addition on
Fraction. I'll refer to all of the above code that doesn't
refer to Fraction, float, or complex as "boilerplate". 'r'
will be an instance of Fraction, which is a subtype of
Rational (r : Fraction <: Rational), and b : B <:
Complex. The first three involve 'r + b':
1. If B <: Fraction, int, float, or complex, we handle
that specially, and all is well.
2. If Fraction falls back to the boilerplate code, and it
were to return a value from __add__, we'd miss the
possibility that B defines a more intelligent __radd__,
so the boilerplate should return NotImplemented from
__add__. In particular, we don't handle Rational
here, even though we could get an exact answer, in case
the other type wants to do something special.
3. If B <: Fraction, Python tries B.__radd__ before
Fraction.__add__. This is ok, because it was
implemented with knowledge of Fraction, so it can
handle those instances before delegating to Real or
Complex.
The next two situations describe 'b + r'. We assume that b
didn't know about Fraction in its implementation, and that it
uses similar boilerplate code:
4. If B <: Rational, then __radd_ converts both to the
builtin rational type (hey look, that's us) and
proceeds.
5. Otherwise, __radd__ tries to find the nearest common
base ABC, and fall back to its builtin type. Since this
class doesn't subclass a concrete type, there's no
implementation to fall back to, so we need to try as
hard as possible to return an actual value, or the user
will get a TypeError.
c���t|t�r �||�St|t�r�|t|��St|t�r�t|�|�St|t�r�t |�|�St
Sro)r?rr>rB�complex�NotImplemented)rj�b�fallback_operator�monomorphic_operators ��r�forwardz-Fraction._operator_fallbacks.<locals>.forwardesq����!�X�&�+�A�q�1�1��A�s�#�+�A�x��{�;�;��A�u�%�(��q��1�5�5��A�w�'�(����Q�7�7�%�%r#�__c�<��t|tj�r�t|�|�St|tj�r�t|�t|��St|tj�r�t|�t|��StSro) r?r@rAr�RealrB�Complexr�r�)r�rjr�r�s ��r�reversez-Fraction._operator_fallbacks.<locals>.reversessp����!�W�-�-�.�+�H�Q�K��;�;��A�w�|�|�,�(��q��5��8�<�<��A�w���/�(����W�Q�Z�@�@�%�%r#�__r)rU�__doc__)r�r�r�r�s`` r�_operator_fallbackszFraction._operator_fallbackssi���`
&� �"3�"<�"<�<�t�C���.�6�6��� &�!�#4�#=�#=�=��D���.�6�6������r#c��|j|j}}|j|j}}tj||�}|dk(r"tj||z||zz||z�S||z}|||zz||zz}tj||�} | dk(rtj|||z�Stj|| z||| zz�S)za + br�r/r0rJrKrrV�
rjr��na�da�nb�dbrO�s�t�g2s
r�_addz
Fraction._add��������q�~�~�B�����q�~�~�B���H�H�R������6��.�.�r�B�w��b��/@�"�r�'�J�J��!�G���"��'�N�R�!�V�#��
�X�X�a��^��
��7��.�.�q�!�b�&�9�9��*�*�1��7�A��r��N�C�Cr#c��|j|j}}|j|j}}tj||�}|dk(r"tj||z||zz
||z�S||z}|||zz||zz
}tj||�} | dk(rtj|||z�Stj|| z||| zz�S)za - brr�r�s
r�_subz
Fraction._sub�r�r#c�.�|j|j}}|j|j}}tj||�}|dkDr
||z}||z}tj||�}|dkDr
||z}||z}tj||z||z�S)za * brr�)rjr�r�r�r�r��g1r�s r�_mulz
Fraction._mul�s������q�~�~�B�����q�~�~�B��
�X�X�b�"�
��
��6��2�I�B��2�I�B�
�X�X�b�"�
��
��6��2�I�B��2�I�B��*�*�2��7�B��G�<�<r#c�r�|j|j}}|dk(rtd|z��|j|j}}tj||�}|dkDr
||z}||z}tj||�}|dkDr
||z}||z}||z||z} }| dkr|| } }t
j
|| �S)za / brr:r)r/r0rIrJrKrrV)
rjr�r�r�r�r�r�r�rrs
r�_divz
Fraction._div�s������q�~�~�B��
��7�#�$5��$:�;�;����q�~�~�B��
�X�X�b�"�
��
��6��2�I�B��2�I�B�
�X�X�b�"�
��
��6��2�I�B��2�I�B��B�w��R��1���q�5��2��r�q�A��*�*�1�a�0�0r#c�h�|j|jz|j|jzzS)za // b)rr�rjr�s r� _floordivzFraction._floordivs'�����a�m�m�+�������1L�M�Mr#c��|j|j}}t|j|z||jz�\}}|t|||z�fS)z(a // b, a % b))rrrr)rjr�r�r��div�n_mods r�_divmodzFraction._divmodsK������
�
�B���A�K�K�"�,�b�1�;�;�.>�?�
��U��H�U�B��G�,�,�,r#c��|j|j}}t|j|z|j|zz||z�S)za % b)rrr)rjr�r�r�s r�_modz
Fraction._mods;������
�
�B������r�)�a�k�k�B�.>�?��b��I�Ir#c��t|tj��r|jdk(r�|j}|dk\r0t
j
|j|z|j|z�S|jdkDr2t
j
|j|z|j|z�S|jdk(rtd|j|zz��t
j
|j|z|j|z�St|�t|�zSt|ttf�rt|�|zStS)z�a ** b
If b is not an integer, the result will be a float or complex
since roots are generally irrational. If b is an integer, the
result will be rational.
rrr:)
r?r@rArrrrVr/r0rIrBr�r�)rjr��powers r�__pow__zFraction.__pow__!s8���a��)�)�*��}�}��!������A�:�#�6�6�q�|�|�u�7L�78�~�~��7N�P�P��\�\�A�%�#�6�6�q�~�~�%��7O�78�|�|��v�7M�O�O��\�\�Q�&�+�,=�,-�N�N�u�f�,D�-E�F�F�$�6�6�����U�F�7R�9:���
�5�&�7P�R�R�
�Q�x�5��8�+�+�
��E�7�+�
,���8�q�=� �!�!r#c�.�|jdk(r|jdk\r||jzSt|tj�r#t|j|j�|zS|jdk(r||jzS|t|�zS)za ** brr) r0r/r?r@rArrrrB)r�rjs r�__rpow__zFraction.__rpow__As{���>�>�Q��1�<�<�1�#4�����$�$��a��)�)�*��A�K�K����7�1�<�<��>�>�Q������$�$��E�!�H�}�r#c�V�tj|j|j�S)z++a: Coerces a subclass instance to Fraction�rrVr/r0rps r�__pos__zFraction.__pos__Os���*�*�1�<�<����H�Hr#c�X�tj|j|j�S)z-ar�rps r�__neg__zFraction.__neg__Ss���*�*�A�L�L�=�!�.�.�I�Ir#c�h�tjt|j�|j�S)zabs(a))rrVr
r/r0rps r�__abs__zFraction.__abs__Ws"���*�*�3�q�|�|�+<�a�n�n�M�Mr#c��|jdkr!||j|jz�S||j|jz�S)zint(a)rr.)rj�_indexs r�__int__zFraction.__int__[sC���<�<�!���Q�\�\�M�Q�^�^�;�<�=�=��!�,�,�!�.�.�8�9�9r#c��|jdkr|j|jzS|j|jzS)z
math.trunc(a)rr.rps r� __trunc__zFraction.__trunc__bs9���<�<�!���l�l�]�a�n�n�4�5�5��<�<�1�>�>�1�1r#c�4�|j|jzS)z
math.floor(a)r.rps r� __floor__zFraction.__floor__is���|�|�q�~�~�-�-r#c�8�|j|jzS)zmath.ceil(a)r.rps r�__ceil__zFraction.__ceil__ms���,�,��!�.�.�0�1�1r#c�&�|�K|j}t|j|�\}}|dz|kr|S|dz|kDr|dzS|dzdk(r|S|dzSdt|�z}|dkDrt t||z�|�St t||z�|z�S)z?round(self, ndigits)
Rounds half toward even.
rdrrr)r0rr/r
r�round)rM�ndigitsr�floor� remainder�shifts r� __round__zFraction.__round__rs���
�?��!�!�A�%�d�o�o�q�9��E�9��1�}�q� ����Q���"��q�y� ����a�����q�y� ��C��L� ���Q�;��E�$��,�/��7�7��E�$��,�/�%�7�8�8r#c�B�t|j|j�S)z
hash(self))rr/r0r`s r�__hash__zFraction.__hash__�s���t����0A�0A�B�Br#c��t|�tur |j|k(xr|jdk(St |t
j�r4|j|jk(xr|j|jk(St |t
j�r|jdk(r|j}t |t�rCtj|�stj|�rd|k(S||j!|�k(St"S)za == brr�)r=r>r/r0r?r@rArrr��imag�realrBrJ�isnan�isinfrXr�r�s r�__eq__zFraction.__eq__�s�����7�c�>��<�<�1�$�<����1�)<�<��a��)�)�*��L�L�A�K�K�/�4��N�N�a�m�m�3�
5��a����)�a�f�f��k����A��a����z�z�!�}��
�
�1�
��a�x���A�L�L��O�+�+�"�!r#c�f�t|tj�r7||j|jz|j
|jz�St|t�rKtj|�stj|�r |d|�S|||j|��StS)acHelper for comparison operators, for internal use only.
Implement comparison between a Rational instance `self`, and
either another Rational instance or a float `other`. If
`other` is not a Rational instance or a float, return
NotImplemented. `op` should be one of the six standard
comparison operators.
r�)
r?r@rAr/rr0rrBrJr�rrXr�)rM�other�ops r�_richcmpzFraction._richcmp�s����e�W�-�-�.��d�o�o��(9�(9�9��'�'�%�/�/�9�;�
;��e�U�#��z�z�%� �D�J�J�u�$5��#�u�~�%��$����� 6�7�7�!�!r#c�B�|j|tj�S)za < b)r�operator�ltr�s r�__lt__zFraction.__lt__�����z�z�!�X�[�[�)�)r#c�B�|j|tj�S)za > b)rr�gtr�s r�__gt__zFraction.__gt__�r
r#c�B�|j|tj�S)za <= b)rr�ler�s r�__le__zFraction.__le__�r
r#c�B�|j|tj�S)za >= b)rr�ger�s r�__ge__zFraction.__ge__�r
r#c�,�t|j�S)za != 0)r�r/rps r�__bool__zFraction.__bool__�s���A�L�L�!�!r#c�J�|j|j|jffSro)rPr/r0r`s r�
__reduce__zFraction.__reduce__�s ��������$�2C�2C� D�E�Er#c�v�t|�tk(r|S|j|j|j�Sro�r=rrPr/r0r`s r�__copy__zFraction.__copy__��.����:��!��K��~�~�d�o�o�t�/@�/@�A�Ar#c�v�t|�tk(r|S|j|j|j�Sror)rM�memos r�__deepcopy__zFraction.__deepcopy__�rr#)rN)i@Bro)HrU�
__module__�__qualname__r�� __slots__r<�classmethodrXr[rVrarCrm�propertyrrrtrwr�r�r�r�add�__add__�__radd__r��sub�__sub__�__rsub__r��mul�__mul__�__rmul__r��truediv�__truediv__�__rtruediv__r��floordiv�__floordiv__�
__rfloordiv__r�r�
__divmod__�__rdivmod__r��mod�__mod__�__rmod__r�r�r�r�r��indexr�r�r�r�r�r�rrr r
rrrrrr�
__classcell__)rPs@rrr�s�����(/�I�g�R�=��=�� ?�� ?�� �� �&�4�7A�r��������C�
B�r)�hk �bD�,�D�(�,�,�?��G�X�D�,�D�(�,�,�?��G�X�=�,�D�(�,�,�?��G�X�1�(!4�D�(�:J�:J� K��K��N�#6�i��AR�AR�"S��L�-�-�2�'�6�B��J��J�
,�D�(�,�,�?��G�X�"�@�I�J�N�#�.�.�:�2�.�2�
9�4C�"�*"�,*�*�*�*�"�F�B�
Br#)F)r�r5r� functoolsrJr@r�re�sys�__all__� hash_info�modulusr�infr� lru_cacher�compile�VERBOSE�
IGNORECASErDr"r,�DOTALL� fullmatchr�rArr�r#r�<module>rGs���6������ �
��,��
�-�-�'�'���m�m��������w�'�*�(�*�@�2�:�:���Z�Z�"�-�-��!��"�:$'�R'1�b�j�j�2��Y�Y�����'�'�Y�$�$|B�w���|Br#