HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_math.cpython-312.opt-1.pyc
�

�h�ec����ddlmZmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZdZed�Zed�Zed�Zej(j*Zej(j.Zd\ZZeezd	k(Zed
k(rej:dZneZe
j@jCe�xse
jDZ#e
j@jIe#d�Z%e
j@jIe#d�Z&d
�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d"d�Z.Gd�d�Z/Gd�de0�Z1Gd�de2�Z3Gd�d�Z4Gd�dejj�Z6Gd�d ejj�Z7d!�Z8ed
k(rejr�yy)#�)�verbose�requires_IEEE_754)�supportNg�h㈵��>�nan�inf�-inf)���7y�ACg�):��@g��7y�AC�__main__zmath_testcases.txtzcmath_testcases.txtc�v�tjdtjd|��d}|dkr|dz}|S)a�Convert a non-NaN float x to an integer, in such a way that
    adjacent floats are converted to adjacent integers.  Then
    abs(ulps(x) - ulps(y)) gives the difference in ulps between two
    floats.

    The results from this function will only make sense on platforms
    where native doubles are represented in IEEE 754 binary64 format.

    Note: 0.0 and -0.0 are converted to 0 and -1, respectively.
    z<qz<drl)�struct�unpack�pack)�x�ns  �5/opt/alt/python312/lib64/python3.12/test/test_math.py�to_ulpsr(s;��	�
�
�d�F�K�K��a�0�1�!�4�A��1�u���g�J���H�c�2�|rdt||dz
z�zSdS)zANumber of '1' bits in binary expansion of a nonnnegative integer.�r)�count_set_bits)rs rrrNs!��,-�1�~�a�!�a�%�i�(�(�4�1�4rc�h�||z
dz	}|sy|dk(r|S||zdz}t||�t||�zS)z�Product of integers in range(start, stop, 2), computed recursively.
    start and stop should both be odd, with start <= stop.

    r)�partial_product)�start�stop�
numfactors�mids    rrrRsL��
��,�1�$�J���	�q�����z�!�Q�&���u�c�*�_�S�$�-G�G�Grc���dx}}tt|j���D]+}|t||dzz	dzdz||z	dzdz�z}||z}�-||t	|�z
zS)z�Factorial of nonnegative integer n, via "Binary Split Factorial Formula"
    described at http://www.luschny.de/math/factorial/binarysplitfact.html

    r)�reversed�range�
bit_lengthrr)r�inner�outer�is    r�py_factorialr$`s}��
��E�E�
�e�A�L�L�N�+�
,���
��!�q�1�u�*��!1�A�!5��Q��!�|�a�7G�H�H��
������Q���*�*�+�+rc��tt|�t|�z
�}t||z
�}||ks||kryd}|j||||�S)z�Given finite floats `expected` and `got`, check that they're
    approximately equal to within the given number of ulps or the
    given absolute tolerance, whichever is bigger.

    Returns None on success and an error message on failure.
    NzAerror = {:.3g} ({:d} ulps); permitted error = {:.3g} or {:d} ulps)�absr�format)�expected�got�ulp_tol�abs_tol�	ulp_error�	abs_error�fmts       r�
ulp_abs_checkr/ksZ���G�H�%����4�5�I��H�s�N�#�I��G��y�G�3��7���z�z�)�Y���A�Arc#�lK�t|d��5}|D]�}d|vr|d|jd�}|j�s�,|jd�\}}|j�\}}}|j�}|d}	|dd}
||t	|�t	|	�|
f����	ddd�y#1swYyxYw�w)z�Parse a file with test values

    -- starts a comment
    blank lines, or lines containing only a comment, are ignored
    other lines are expected to have the form
      id fn arg -> expected [flag]*

    �utf-8��encoding�--N�->rr)�open�index�strip�split�float)�fname�fp�line�lhs�rhs�id�fn�arg�
rhs_pieces�exp�flagss           r�parse_mtestfilerF}s�����
�e�g�	&�:�"��
	:�D��t�|��-�T�Z�Z��-�.���:�:�<���z�z�$�'�H�C���)�)�+�K�B��C�����J��Q�-�C��q�r�N�E��r�5��:�u�S�z�5�9�9�
	:�:�:�:�s�B4�BB(�	B4�(B1�-B4c
#�K�t|d��5}|D]�}|jd�s|j�s�%|jd�\}}|j�\}}}}|j�}	|	d|	d}}
|	dd}||t	|�t	|�t	|
�t	|�|f����	ddd�y#1swYyxYw�w)	z�Parse a file with test values

    Empty lines or lines starting with -- are ignored
    yields id, fn, arg_real, arg_imag, exp_real, exp_imag
    r1r2r4r5rr�N)r6�
startswithr8r9r:)
r;r<r=r>r?r@rA�arg_real�arg_imagrC�exp_real�exp_imagrEs
             r�parse_testfilerN�s�����
�e�g�	&��"��	�D����t�$�D�J�J�L���z�z�$�'�H�C��),����&�B��H�h�����J�!+�A��
�1�
�h�H��q�r�N�E��r���?�E�(�O���?�E�(�O���
�	����s�C�B!B;�2	C�;C�Cc�&�||k(ryd}t|t�rt|t�rt|�}n+t|t�rt|t�rt|�}t|t�rvt|t�rftj|�rtj|�rd}n9tj
|�stj
|�rnt
||||�}|�*d}|j||�}|dj|�z
}|Sy)a�Compare arguments expected and got, as floats, if either
    is a float, using a tolerance expressed in multiples of
    ulp(expected) or absolutely (if given and greater).

    As a convenience, when neither argument is a float, and for
    non-finite floats, exact equality is demanded. Also, nan==nan
    as far as this function is concerned.

    Returns None on success and an error message on failure.
    Nz	not equalzexpected {!r}, got {!r}z ({}))�
isinstancer:�int�math�isnan�isinfr/r')r(r)r*r+�failure�fail_fmt�fail_msgs       r�result_checkrX�s����h����G��(�E�"�z�#�s�';��C�j��	�C��	�J�x��$=���?���(�E�"�z�#�u�'=��:�:�h��D�J�J�s�O��G�
�Z�Z��
!�T�Z�Z��_��$�H�c�7�G�D�G���,���?�?�8�S�1���G�N�N�7�+�+����rc��eZdZd�Zd�Zy)�	FloatLikec��||_y�N��value��selfr^s  r�__init__zFloatLike.__init__��	����
rc��|jSr\r]�r`s r�	__float__zFloatLike.__float__�����z�z�rN)�__name__�
__module__�__qualname__rare�rrrZrZ�����rrZc��eZdZy)�IntSubclassN�rgrhrirjrrrmrm�s��rrmc��eZdZd�Zd�Zy)�MyIndexablec��||_yr\r]r_s  rrazMyIndexable.__init__�rbrc��|jSr\r]rds r�	__index__zMyIndexable.__index__�rfrN�rgrhrirarsrjrrrprp�rkrrpc��eZdZdd�Zy)�BadDescrNc��t�r\)�
ValueError)r`�obj�objtypes   r�__get__zBadDescr.__get__�s���rr\)rgrhrir{rjrrrvrv�s��rrvc�Z�eZdZdRd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
ed
��Zd�Zej$ej(dk(xrej*�dvd�d��Zd�Zd�Zd�Zd�Zd�Zd�Zej<d��Zd�Z d�Z!d�Z"eej$e#d�d���Z$d�Z%d �Z&eej$e#d!�d"���Z'd#�Z(d$�Z)d%�Z*d&�Z+d'�Z,d(�Z-d)�Z.ed*��Z/eej`d+d�d,���Z1d-�Z2d.�Z3eej$e#d/�ej<d0����Z4ejjd1�d2��Z6eej$e#d/�ej<ejjd1�d3�����Z7d4�Z8d5�Z9d6�Z:ed7��Z;d8�Z<d9�Z=d:�Z>d;�Z?d<�Z@ed=��ZAd>�ZBd?�ZCd@�ZDdA�ZEdB�ZFdC�ZGej�eIdD�dE��ZJedF��ZKedG��ZLdH�ZMdI�ZNdJ�ZOedK��ZPedL��ZQdM�ZRdN�ZSdO�ZTdP�ZUyQ)S�	MathTests�c�h�t||||�}|�"|jdj||��yy)aaCompare arguments expected and got, as floats, if either
        is a float, using a tolerance expressed in multiples of
        ulp(expected) or absolutely, whichever is greater.

        As a convenience, when neither argument is a float, and for
        non-finite floats, exact equality is demanded. Also, nan==nan
        in this function.
        Nz{}: {})rX�failr')r`�namer)r(r*r+rUs       r�ftestzMathTests.ftest�s6���x��g�w�?�����I�I�h�o�o�d�G�4�5�rc���|jdtjd�|jdtjd�|j	tj
dtjz�y)N�pig-DT�!	@�egiW�
�@rH)r�rRr�r��assertEqual�taurds r�
testConstantszMathTests.testConstantssH���
�
�4����"<�=��
�
�3���� :�;�������1�T�W�W�9�-rc�8�|jttj�|j	dtjd�tj
�|j	dtjd�tj
dz�|j	dtjd�d�|jttjt�|jttjt�|jttjdtz�|jttjdtz
�|jtjtjt���y)Nzacos(-1)���zacos(0)rrHzacos(1)r)
�assertRaises�	TypeErrorrR�acosr�r�rx�INF�NINF�eps�
assertTruerS�NANrds r�testAcoszMathTests.testAcoss������)�T�Y�Y�/��
�
�:�t�y�y��}�d�g�g�6��
�
�9�d�i�i��l�D�G�G�A�I�6��
�
�9�d�i�i��l�A�.����*�d�i�i��5����*�d�i�i��6����*�d�i�i��S��9����*�d�i�i��c��:�����
�
�4�9�9�S�>�2�3rc��|jttj�|j	dtjd�d�|j	dtjd�d�|jt
tjd�|jt
tjd�|j
tjt�t�|jt
tjt�|jtjtjt���y)Nzacosh(1)rrzacosh(2)rHg5�qB�?r�)r�r�rR�acoshr�rxr�r�r�r�rSr�rds r�	testAcoshzMathTests.testAcoshs������)�T�Z�Z�0��
�
�:�t�z�z�!�}�a�0��
�
�:�t�z�z�!�}�.@�A����*�d�j�j�!�4����*�d�j�j�"�5�������C��#�.����*�d�j�j�$�7�����
�
�4�:�:�c�?�3�4rc�@�|jttj�|j	dtjd�tj
dz�|j	dtjd�d�|j	dtjd�tj
dz�|jttjt�|jttjt�|jttjdtz�|jttjdtz
�|jtjtjt���y)Nzasin(-1)r�rHzasin(0)rzasin(1)r)
r�r�rR�asinr�r�rxr�r�r�r�rSr�rds r�testAsinzMathTests.testAsins������)�T�Y�Y�/��
�
�:�t�y�y��}�t�w�w�h�q�j�9��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��l�D�G�G�A�I�6����*�d�i�i��5����*�d�i�i��6����*�d�i�i��S��9����*�d�i�i��c��:�����
�
�4�9�9�S�>�2�3rc�Z�|jttj�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�|jtjt�t�|jtjt�t�|jtjtjt���y)	Nzasinh(0)rzasinh(1)rg'�ya64�?z	asinh(-1)r�g'�ya64�)r�r�rR�asinhr�r�r�r�r�rSr�rds r�	testAsinhzMathTests.testAsinh's������)�T�Z�Z�0��
�
�:�t�z�z�!�}�a�0��
�
�:�t�z�z�!�}�.A�B��
�
�;��
�
�2��0D�E�������C��#�.�������D�)�4�0�����
�
�4�:�:�c�?�3�4rc���|jttj�|j	dtjd�tj
dz�|j	dtjd�d�|j	dtjd�tj
dz�|j	dtjt�tj
d	z�|j	d
tjt�tj
d	z�|jtjtjt���y)Nzatan(-1)r��zatan(0)rzatan(1)rz	atan(inf)rHz
atan(-inf))r�r�rR�atanr�r�r�r�r�rSr�rds r�testAtanzMathTests.testAtan0s������)�T�Y�Y�/��
�
�:�t�y�y��}�t�w�w�h�q�j�9��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��l�D�G�G�A�I�6��
�
�;��	�	�#������	�:��
�
�<����4��4�7�7�(�1�*�=�����
�
�4�9�9�S�>�2�3rc���|jttj�|j	dtj
d�d�|j	dtj
d�d�|j	dtj
d�d�|jttj
d	�|jttj
d
�|jttj
t�|jttj
t�|jtjtj
t���y)Nzatanh(0)rz
atanh(0.5)��?g�z��?zatanh(-0.5)��g�z��rr�)r�r�rRr�r��atanhrxr�r�r�rSr�rds r�	testAtanhzMathTests.testAtanh9s������)�T�Y�Y�/��
�
�:�t�z�z�!�}�a�0��
�
�<����C��2E�F��
�
�=�$�*�*�T�"2�4H�I����*�d�j�j�!�4����*�d�j�j�"�5����*�d�j�j�#�6����*�d�j�j�$�7�����
�
�4�:�:�c�?�3�4rc��|jttj�|j	dtjdd�tj
dz�|j	dtjdd�tj
dz�|j	dtjdd�d�|j	d	tjdd�tj
dz�|j	d
tjdd�tj
dz�|j	dtjdd�dtj
zdz�|j	d
tjdt�tj
�|j	dtjdd�tj
�|j	dtjdd�tj
�|jtjdd�d�|jtjdd�d�|jtjdt�d�|jtjtjdt���|j	dtjdt�tj
�|j	dtjdd�tj
�|j	dtjdd�tj
�|jtjdd�d�|jtjdd�d�|jtjdt�d�|jtjtjdt���|j	dtjtt�tj
dzdz�|j	dtjtd�tj
dz�|j	dtjtd�tj
dz�|j	dtjtd�tj
dz�|j	dtjtd�tj
dz�|j	dtjtt�tj
dz�|jtjtjtt���|j	dtjtt�tj
dzdz�|j	dtjtd�tj
dz�|j	dtjtd�tj
dz�|j	d tjtd�tj
dz�|j	d!tjtd�tj
dz�|j	d"tjtt�tj
dz�|jtjtjtt���|j	d#tjdt�tj
�|j	d$tjdd�tj
dz�|j	d%tjdd�tj
dz�|jtjdt�d�|jtjtjdt���|j	d&tjdt�tj
�|j	d'tjdd�tj
dz�|j	d(tjdd�tj
dz�|jtjdt�d�|jtjtjdt���|jtjtjtt���|jtjtjtd���|jtjtjtd���|jtjtjtd���|jtjtjtd���|jtjtjtt���|jtjtjtt���y))Nzatan2(-1, 0)r�rrHzatan2(-1, 1)rr�zatan2(0, 1)zatan2(1, 1)zatan2(1, 0)zatan2(1, -1)�zatan2(0., -inf)�zatan2(0., -2.3)�ffffff�zatan2(0., -0.)���ffffff@zatan2(-0., -inf)zatan2(-0., -2.3)zatan2(-0., -0.)zatan2(inf, -inf)zatan2(inf, -2.3)zatan2(inf, -0.)zatan2(inf, 0.)zatan2(inf, 2.3)zatan2(inf, inf)zatan2(-inf, -inf)zatan2(-inf, -2.3)zatan2(-inf, -0.)zatan2(-inf, 0.)zatan2(-inf, 2.3)zatan2(-inf, inf)zatan2(2.3, -inf)zatan2(2.3, -0.)zatan2(2.3, 0.)zatan2(-2.3, -inf)zatan2(-2.3, -0.)zatan2(-2.3, 0.))r�r�rR�atan2r�r�r�r�r�r�rSr�rds r�	testAtan2zMathTests.testAtan2Ds������)�T�Z�Z�0��
�
�>�4�:�:�b�!�#4�t�w�w�h�q�j�A��
�
�>�4�:�:�b�!�#4�t�w�w�h�q�j�A��
�
�=�$�*�*�Q��"2�A�6��
�
�=�$�*�*�Q��"2�D�G�G�A�I�>��
�
�=�$�*�*�Q��"2�D�G�G�A�I�>��
�
�>�4�:�:�a��#4�a����i��k�B�	
�
�
�$�d�j�j��T�&:�D�G�G�D��
�
�$�d�j�j��T�&:�D�G�G�D��
�
�#�T�Z�Z��C�%8�$�'�'�B�������B��+�R�0�������B��,�b�1�������B��,�b�1�����
�
�4�:�:�b�#�#6�7�8��
�
�%�t�z�z�#�t�'<�t�w�w�h�G��
�
�%�t�z�z�#�t�'<�t�w�w�h�G��
�
�$�d�j�j��c�&:�T�W�W�H�E�������C��,�c�2�������C��-�s�3�������C��-�s�3�����
�
�4�:�:�c�3�#7�8�9��
�
�%�t�z�z�#�t�'<�d�g�g�a�i��k�J��
�
�%�t�z�z�#�t�'<�d�g�g�a�i�H��
�
�$�d�j�j��d�&;�T�W�W�Q�Y�G��
�
�#�T�Z�Z��S�%9�4�7�7�1�9�E��
�
�$�d�j�j��c�&:�D�G�G�A�I�F��
�
�$�d�j�j��c�&:�D�G�G�A�I�F�����
�
�4�:�:�c�3�#7�8�9��
�
�&��
�
�4��(>������
�1��M��
�
�&��
�
�4��(>������
�K��
�
�%�t�z�z�$��'=����x��z�J��
�
�$�d�j�j��s�&;�d�g�g�X�a�Z�H��
�
�%�t�z�z�$��'<�t�w�w�h�q�j�I��
�
�%�t�z�z�$��'<�t�w�w�h�q�j�I�����
�
�4�:�:�d�C�#8�9�:��
�
�%�t�z�z�#�t�'<�d�g�g�F��
�
�$�d�j�j��c�&:�D�G�G�A�I�F��
�
�#�T�Z�Z��R�%8�$�'�'�!�)�D�������C��-�r�2�����
�
�4�:�:�c�3�#7�8�9��
�
�&��
�
�4��(>�����I��
�
�%�t�z�z�$��'<�t�w�w�h�q�j�I��
�
�$�d�j�j��r�&:�T�W�W�H�Q�J�G�������D�#�.��4�����
�
�4�:�:�d�C�#8�9�:�����
�
�4�:�:�c�4�#8�9�:�����
�
�4�:�:�c�4�#8�9�:�����
�
�4�:�:�c�3�#7�8�9�����
�
�4�:�:�c�2�#6�7�8�����
�
�4�:�:�c�3�#7�8�9�����
�
�4�:�:�c�3�#7�8�9�����
�
�4�:�:�c�3�#7�8�9rc�n�|jttj�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�|j	dtjd	�d	�|j	d
tjd�d�|j	dtjd
�d�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�|jtjt�t�|jtjt�t�|jtjtjt���y)Nzcbrt(0)rzcbrt(1)rzcbrt(8)�rHz	cbrt(0.0)r�z
cbrt(-0.0)r�z	cbrt(1.2)g333333�?ggA�E��?z
cbrt(-2.6)g�������g�L]6H��zcbrt(27)�r�zcbrt(-1)r�z	cbrt(-27)i�����)r�r�rR�cbrtr�r�r�r�r�rSr�rds r�testCbrtzMathTests.testCbrt�sU�����)�T�Y�Y�/��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��l�A�.��
�
�;��	�	�#���4��
�
�<����4��$�7��
�
�;��	�	�#��0A�B��
�
�<����4��2D�E��
�
�:�t�y�y��}�a�0��
�
�:�t�y�y��}�b�1��
�
�;��	�	�#���3�������3���-�������4��$�/�����
�
�4�9�9�S�>�2�3rc�r�|jttj�|j	t
t
tjd���|j	tjd�d�|j	tjd�d�|j	tjd�d�|j	tjd�d�|j	tjd�d	�|j	tjd
�d	�|j	tjd�d�|j	tjd�d�Gd
�d�}Gd�dt�}Gd�d�}Gd�d�}|j	tj|��d�|j	tj|��d�|j	tjtd��d�|jttj|��|jttj|��|�}d�|_
|jttj|�|jttj|d�|j	tjtd��d�|j	tjtd��d�y)Nr�r��?��?rHr�r��r����r�r�c��eZdZd�Zy)�$MathTests.testCeil.<locals>.TestCeilc��y�N�*rjrds r�__ceil__z-MathTests.testCeil.<locals>.TestCeil.__ceil__����rN�rgrhrir�rjrr�TestCeilr�����
rr�c��eZdZd�Zy)�%MathTests.testCeil.<locals>.FloatCeilc��yr�rjrds rr�z.MathTests.testCeil.<locals>.FloatCeil.__ceil__�r�rNr�rjrr�	FloatCeilr��r�rr�c��eZdZy)�&MathTests.testCeil.<locals>.TestNoCeilNrnrjrr�
TestNoCeilr�����rr�c��eZdZe�Zy)�'MathTests.testCeil.<locals>.TestBadCeilN)rgrhrirvr�rjrr�TestBadCeilr��s	���z�Hrr�r�g@E@�+c��|Sr\rj��argss r�<lambda>z$MathTests.testCeil.<locals>.<lambda>�s��4�r)r�r�rR�ceilr�rQ�typer:rZrxr�)r`r�r�r�r��ts      r�testCeilzMathTests.testCeil�s�����)�T�Y�Y�/�����d�4�9�9�S�>�2�3�������3���+�������3���+�������3���+�������4��!�,�������4��"�-�������4��"�-�������3���+�������4��!�,�
	�	�	��	�	�	�	"�	"�������8�:�.��3�������9�;�/��4�������9�T�?�3�R�8����)�T�Y�Y�
��=����*�d�i�i���?��L��'��
����)�T�Y�Y��2����)�T�Y�Y��1�5�������9�T�?�3�T�:�������9�T�?�3�T�:rc���|jtjdd�d�|jtjdd�d�|jtjdd�d�|jtjdd�d�|jtjd	d
�d�|jttj�|jtjdd�d�|jtjdd
�d�|jtjt
d�t
�|jtjt
d
�t�|jtjtd�t
�|jtjtd
�t�|jtjdt
�d�|jtjdt�d�|jtjt
t
�t
�|jtjt
t�t�|jtjtt
�t
�|jtjtt�t�|jtjtjtd���|jtjtjtt
���|jtjtjtt���|jtjtjtt���|jtjtjt
t���|jttjdt��d�y)
Nrr�r�r�i���r�r��@�@r����@)r�rR�copysignr�r�r�r�r�rSr�rTr&rds r�testCopysignzMathTests.testCopysign�s���������q�"�-�s�3�������r�2�.��4�������r�3�/��6�������q�"�-�s�3�������r�3�/��6����)�T�]�]�3�������r�2�.��3�������r�3�/��5�������s�B�/��5�������s�C�0�$�7�������t�R�0�#�6�������t�S�1�4�8�������r�3�/��4�������r�4�0�#�6�������s�C�0�#�6�������s�D�1�4�8�������t�S�1�3�7�������t�T�2�D�9�����
�
�4�=�=��b�#9�:�;�����
�
�4�=�=��c�#:�;�<�����
�
�4�=�=��d�#;�<�=�����
�
�4�=�=��c�#:�;�<�	
����
�
�4�=�=��c�#:�;�<�����T�]�]�2�s�3�4�b�9rc�X�|jttj�|j	dtjtj
dz�dtjd���|j	dtjd�d�|j	dtjtj
dz�dtjd���|j	dtjtj
�d	�	|jtjtjt���|jtjtjt���|jtjtjt���y#t$rU|jttjt�|jttjt�Y��wxYw)
Nz
cos(-pi/2)rHrr�r+zcos(0)z	cos(pi/2)zcos(pi)r�)
r�r�rR�cosr�r��ulpr�rSr�r�rxr�rds r�testCoszMathTests.testCos�sB�����)�T�X�X�.��
�
�<����4�7�7�(�1�*�!5�q�$�(�(�1�+�
�N��
�
�8�T�X�X�a�[�!�,��
�
�;��������� 3�Q������
�L��
�
�9�d�h�h�t�w�w�/��4�	:��O�O�D�J�J�t�x�x��}�5�6��O�O�D�J�J�t�x�x��~�6�7�	
����
�
�4�8�8�C�=�1�2���	:����j�$�(�(�C�8����j�$�(�(�D�9�	:�s�A6G�AH)�(H)�win32)�ARM�ARM64zEWindows UCRT is off by 2 ULP this test requires accuracy within 1 ULPc�F�|jttj�|j	dtjd�d�|j	dtjd�dtjd�dzzz
d�|jtjt�t�|jtjt�t�|jtjtjt���y)Nzcosh(0)rrzcosh(2)-2*cosh(1)**2rHr�)r�r�rR�coshr�r�r�r�r�rSr�rds r�testCoshzMathTests.testCosh�s���	
���)�T�Y�Y�/��
�
�9�d�i�i��l�A�.��
�
�)�4�9�9�Q�<��$�)�)�A�,��/�8I�+I�2�N�������3���-�������4��#�.�����
�
�4�9�9�S�>�2�3rc���|jttj�|j	dtjtj
�d�|j	dtjtj
dz�d�|j	dtjtj
dz�d�|j	d	tjd
�d
�y)Nzdegrees(pi)g�f@z
degrees(pi/2)rHg�V@zdegrees(-pi/4)r�g�F�z
degrees(0)r)r�r�rR�degreesr�r�rds r�testDegreeszMathTests.testDegrees�s������)�T�\�\�2��
�
�=�$�,�,�t�w�w�"7��?��
�
�?�D�L�L������$;�T�B��
�
�#�T�\�\�4�7�7�(�1�*�%=�u�E��
�
�<����a��!�4rc���|jttj�|j	dtjd�dtj
z�|j	dtjd�d�|j	dtjd�tj
�|j
tjt�t�|j
tjt�d�|jtjtjt���|jttjd�y)	Nzexp(-1)r�rzexp(0)rzexp(1)r��@B)
r�r�rRrDr�r�r�r�r�r�rSr��
OverflowErrorrds r�testExpzMathTests.testExp�s������)�T�X�X�.��
�
�9�d�h�h�r�l�A�d�f�f�H�5��
�
�8�T�X�X�a�[�!�,��
�
�8�T�X�X�a�[�$�&�&�1�������#���,�������$���,�����
�
�4�8�8�C�=�1�2����-����7�;rc���|jttj�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�|j	d	tjd
�d�|jtjt�t�|jtjt�d�|jtjtjt���|jttjd
�y)Nzexp2(-1)r�r�zexp2(0)rrzexp2(1)rHz	exp2(2.3)r�g)��{IJ@r�r�)r�r�rR�exp2r�r�r�r�r�rSr�r�rds r�testExp2zMathTests.testExp2s������)�T�Y�Y�/��
�
�:�t�y�y��}�c�2��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��l�A�.��
�
�;��	�	�#��0A�B�������3���-�������4��"�-�����
�
�4�9�9�S�>�2�3����-����G�<rc�0�|jttj�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�y)Nzfabs(-1)r�rzfabs(0)rzfabs(1))r�r�rR�fabsr�rds r�testFabszMathTests.testFabss^�����)�T�Y�Y�/��
�
�:�t�y�y��}�a�0��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��l�A�.rc��|jtjd�d�d}tdd�D]Z}||z}|jtj|�|�|jtj|�t	|���\|jttjd�|jttjddz�y)Nrr��r��
�d)r�rR�	factorialrr$r�rx)r`�totalr#s   r�
testFactorialzMathTests.testFactorials����������*�A�.����q�$��	A�A��Q�J�E����T�^�^�A�.��6����T�^�^�A�.��Q��@�	A�	
���*�d�n�n�b�9����*�d�n�n�r�3�w�h�?rc�V�|jttjd�|jttjd�|jttjd�|jttjd�|jttjt	j
d��|jttjt	j
d��|jttjd�y)N�@g������@r��}Ô%�I���5z5.2)r�r�rRr��decimal�Decimalrds r�testFactorialNonIntegersz"MathTests.testFactorialNonIntegerss������)�T�^�^�S�9����)�T�^�^�S�9����)�T�^�^�T�:����)�T�^�^�V�<����)�T�^�^�W�_�_�S�5I�J����)�T�^�^�W�_�_�U�5K�L����)�T�^�^�S�9rc��|jttjddz�|jttjd�y)Nr�r��}Ô%�I�T)r�r�rRr�r�rds r�testFactorialHugeInputsz!MathTests.testFactorialHugeInputs)s4��	
���-�����S��A����)�T�^�^�U�;rc���|jttj�|j	t
t
tjd���|j	tjd�d�|j	tjd�d�|j	tjd�d�|j	tjd�d�|j	tjd�d�|j	tjd	�d
�Gd�d�}Gd
�dt�}Gd�d�}Gd�d�}|j	tj|��d�|j	tj|��d�|j	tjtd��d�|jttj|��|jttj|��|�}d�|_
|jttj|�|jttj|d�|j	tjtd��d�|j	tjtd��d�y)Nr�rr�rr�r�r�r�r����c��eZdZd�Zy)�&MathTests.testFloor.<locals>.TestFloorc��yr�rjrds r�	__floor__z0MathTests.testFloor.<locals>.TestFloor.__floor__>r�rN�rgrhrirrjrr�	TestFloorr
=r�rrc��eZdZd�Zy)�'MathTests.testFloor.<locals>.FloatFloorc��yr�rjrds rrz1MathTests.testFloor.<locals>.FloatFloor.__floor__Ar�rNr
rjrr�
FloatFloorr@r�rrc��eZdZy)�(MathTests.testFloor.<locals>.TestNoFloorNrnrjrr�TestNoFloorrCr�rrc��eZdZe�Zy)�)MathTests.testFloor.<locals>.TestBadFloorN)rgrhrirvrrjrr�TestBadFloorrE�	�� �
�Irrr�g33333�D@�)c��|Sr\rjr�s rr�z%MathTests.testFloor.<locals>.<lambda>Ns��D�r)r�r�rR�floorr�rQr�r:rZrxr)r`rrrrr�s      r�	testFloorzMathTests.testFloor0s������)�T�Z�Z�0�����d�4�:�:�c�?�3�4�������C��!�,�������C��!�,�������C��!�,�������D�)�2�.�������D�)�2�.�������D�)�2�.�
	�	�	��	�	�	�	#�	#�������I�K�0�"�5�������J�L�1�2�6�������I�d�O�4�b�9����)�T�Z�Z���?����*�d�j�j�,�.�A��M��(������)�T�Z�Z��3����)�T�Z�Z��A�6�������I�d�O�4�d�;�������I�d�O�4�d�;rc�$�|jttj�|j	dtjdd�d�|j	dtjdd�d�|j	dtjdd�d	�|j	d
tjdd�d�|j	d
tjdd�d�|j	dtjdd�d�|jtjtjtd	���|jtjtjd	t���|jtjtjtt���|jttjd	d�|jttjtd	�|jttjtd	�|jttjtd�|jtjdt�d�|jtjdt�d�|jtjdt�d�|jtjdt�d�|jtjdd�d�|jtjdt�d�|jttjtt�y)Nzfmod(10, 1)r�rr�z
fmod(10, 0.5)r�z
fmod(10, 1.5)r�r�zfmod(-10, 1)���r�zfmod(-10, 0.5)zfmod(-10, 1.5)r�r���)r�r�rR�fmodr�r�rSr�rxr�r�r�rds r�testFmodzMathTests.testFmodUs4�����)�T�Y�Y�/��
�
�=�$�)�)�B��"2�C�8��
�
�?�D�I�I�b�#�$6��<��
�
�?�D�I�I�b�#�$6��<��
�
�>�4�9�9�S�!�#4�d�;��
�
�#�T�Y�Y�s�C�%8�$�?��
�
�#�T�Y�Y�s�C�%8�$�?�����
�
�4�9�9�S�"�#5�6�7�����
�
�4�9�9�R��#5�6�7�����
�
�4�9�9�S�#�#6�7�8����*�d�i�i��R�8����*�d�i�i��b�9����*�d�i�i��r�:����*�d�i�i��b�9�������3��,�c�2�������4��-�t�4�������3��-�s�3�������4��.��5�������3��,�c�2�������3��-�s�3����*�d�i�i��c�:rc�|���jttj��fd�}|dtjd�d�|dtjd�d�|dtjd	�d
�|dtjd�d
��j	tjt
�dt
��j	tjt�dt��jtjtjt�d��y)Nc���||c\}}\}}t||z
�tkDs||k7r�j|�d|�d|���yy�Nz
 returned z, expected �r&r�r�)r��resultr(�mantrD�emant�eexpr`s       �r�	testfrexpz&MathTests.testFrexp.<locals>.testfrexposJ���)/��&�K�T�3��%���4��:���$��t���	�	����3�4�)4rz	frexp(-1)r�)r�rzfrexp(0)r�rrzfrexp(1)r)r�rzfrexp(2)rH)r�rH)
r�r�rR�frexpr�r�r�r�rSr�)r`r+s` r�	testFrexpzMathTests.testFrexpls�������)�T�Z�Z�0�	4�	�+�t�z�z�"�~�y�9��*�d�j�j��m�V�4��*�d�j�j��m�X�6��*�d�j�j��m�X�6�������C���+�S�1�������D�)�!�,�d�3�����
�
�4�:�:�c�?�1�#5�6�7rz2fsum is not exact on machines with double roundingc�����ddlm}|j�|j�z
���fd�}gdfdgdfgd�dfgd�dfgd�d	fgd
�dfgd�d
fgd�dft	dd�D�cgc]}d|z��	c}t
j
d�ft	dd�D�cgc]
}d|z|z��c}t
j
d�fgd�dfgd�dft	ddd�D�cgc]}d|zd|dzzz
d|dzzz��c}dgzt
j
d �fg
}t	d�D�cgc]}d!|z��	}}|jt	d"�D�cgc]}||dz||z
��c}|d"gz|df�t|�D]0\}\}}	tj|�}	|j	|��2dd%lm}
m}m}t	d"�D]�}
gd&�d'z}d}t	d(�D],}|d|
��d)z|z
}||z
}|j|��.||�||�}|j||�tj|����|jtjdtj$g�tj$�|j'tj(tjtj*dg���|jtjd*t-d�d+dd,t-d�d-g�d�|j/ttjd.d.g�|j/ttjtj$tj$g�|j/t0tjd/g�|j/t0tjd�|j/ttjd'd"zg�d0�}|j/t2tj|��ycc}wcc}wcc}wcc}wcc}w#t$r|jd#|||fz�Y���t$r|jd$|||fz�Y���wxYw)1Nr)�
float_infoc	����d\}}|D][}tj|�\}}ttj|�	��|�	z
}}||kDr|||z
z}|}n|||z
z}||z
}�]t	tt
t|���dz
�	z
�|z
�}|dkDr1d|dz
z}|d|zzt||zxr|d|zdz
z�z}||z
}tj||�S)z�Full precision summation.  Compute sum(iterable) without any
            intermediate accumulation of error.  Based on the 'lsum' function
            at http://code.activestate.com/recipes/393090/

            r,rHrrr�)	rRr-rQ�ldexp�max�len�binr&�bool)
�iterable�tmant�texprr(rD�tail�h�etiny�mant_digs
        ��r�msumz MathTests.testFsum.<locals>.msum�s�����K�E�4��
�� �J�J�q�M�	��c���
�
�4�� :�;�S�8�^�c���#�:��d�3�h�&�E��D��S��X�%�D���
��
��s�3�s�5�z�?�+�A�-��8�%�$�,�G�D��a�x��$�q�&�M���!�A�#���e�a�i�.I�E�A�a�C��E�M�)J�J�������:�:�e�T�*�*rr�)rr�r��0��.�++�d~�QJr��d~�Q�r?)rr�r�r?r@r�rA)�@Cr�g��g������?C)rBr���9g@C)g@Cr�rCg@C)g������?Cr�g�<g������?Cri�r�z0x1.df11f45f4e61ap+2r�z-0x1.62a2af1bd3624p-1)r	r�缉ؗ�Ҝ<g��7y�AC)g��7y�ACg�������?g��7y�A�g�����������i�rHr��2�4g�z0x1.5555555555555p+970g333333�?r�zDtest %d failed: got OverflowError, expected %r for math.fsum(%.100r)zAtest %d failed: got ValueError, expected %r for math.fsum(%.100r))�random�gauss�shuffle)�ri����r�gh�$.5���g#B����;r���rKrr�r@rA�������spamc3�K�d��t��w�Nr�)�ZeroDivisionErrorrjrr�bad_iterz$MathTests.testFsum.<locals>.bad_iter�s�����I�#�#�s�
)�sysr0r=�min_exprr:�fromhex�append�	enumeraterR�fsumr�r�rxr�rHrIrJrr�rSrrZr�r�rQ)r`r0r>r�test_valuesr#�terms�valsr(�actualrHrIrJ�j�s�vrRr<r=s                 @@r�testFsumzMathTests.testFsum~s���	#��&�&���"�"�X�-��	+�8��I��U�C�L�
<�f�E�
:�F�C�
'��5�
&��4�
+�\�:�
)�;�7�!�!�T�N�
+�q�b��d�
+�
�]�]�1�
2�
4�"'��4�.�
1�Q�s�Q�h�q�j�
1�
�]�]�2�
3�
5�
� 3�4�
=�s�C�7<�U�C��7K�
L�!�b�!�e�b�1�R�4�j� �2��"��:�-�
L��[��
�]�]�3�
4�
6�!��,"'�t��-�A��a��-��-����,1�$�K�8�q�U�1�Q�3�Z�%��(�
"�8�U�4�[�L�>�I�
�1�X�I�
�	�
$-�[�#9�		/��A���h�
I����4���
���V�X�.�		/�	2�1��t��
	:�A�8�2�=�D��A��3�Z�
���!�V�X�&�!�+�a�/���Q������A��
�
�D�M��T�
�A����T�$�Z����4��9�
	:�	
������C����?�3�T�X�X�>�����
�
�4�9�9�d�h�h��_�#=�>�?�������E�9�S�>�6�6�$(�)�D�/�5�$B�C�DJ�	L����-����V�V�4D�E����*�d�i�i�$�(�(�T�X�X�I�1F�G����)�T�Y�Y���9����)�T�Y�Y��2����-����R��X�J�?�	$�	
���+�T�Y�Y��
�C��s,��
1��
M��.��8��!�
I��	�	�2�56��$�4G�H�I��
I��	�	�2�56��$�4G�H�I�
I�s6�P�P�
P�P�;P$�:P)�) Q/�Q/�.Q/c� �tj}|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d	�|j|dd
�d	�|j|dd�d
�d}d}dD]�}||z}||z}|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|���|j|�d�|j|d�d�|j|d
�d�|j|ddd�d�|j|ddd�d�|jt|d�|jt|dd�|jt|dd�|jt|ddd�|j|td�td��d	�y)Nrrr�rK�����x�T����� j9W P)�}� "o�`T"-� l�8P9�cC�/�[�N
S�9�b�Xl	9@{�wM�2�75�k )��	lZ��'^%#�>�;�*Q!/61^�f��^@�U@)rR�gcdr�r�r�rp)r`rpr�y�c�a�bs       r�testGcdzMathTests.testGcd�s����h�h������Q���A�&�����Q���A�&�����R���Q�'�����Q���A�&�����Q���Q�'�����Q���A�&�����Q���Q�'�����S�"��q�)�����S�"��r�*�����R����+�����9�8�:�;=�	?�
O��4��V�	-�A��A��A��A��A����S��A�Y��*����S��A�Y��*����S�!��Q�Z��+����S��Q�B�Z��+����S��Q�B�Z��+����S�!��Q�Z��+����S�!��a�R�[�!�,����S�!��a�R�[�!�,�	-�	
������"�����S��3�'�����T��C�(�����S�"�c�*�A�.�����S�!�R��!�,����)�S�%�0����)�S�%��4����)�S�#�t�4����)�S�#�q�$�7�����[��-�{�2��?��Drc�
�ddlm}ddlm}tj
}tjtjt	jd�t	jd�t	jd�f}tt|�dz�D]@}|j||d|�t	jtd�|d|D�����B|j|d	d
�d�|j|dd
�d�|j|dd�t	jd��|j|dt!d��t	jd��|j||d�|d
��d�|j||dd�|d
d��|dd��|j|t#d�t#d�t#d�t#d��t	jd��|j|dd�d�|j|d�d�|j|�d�|jdt	j$d|d���|j|ddd�|ddd��|j't(�5|d��ddd�|j't(�5|ddd�ddd�dt*j,j.d
zz}|j't0t2f�5|d|�ddd�|j|t4�t4�|j|dt4�t4�|j|dt4�t4�|j|d t4�t4�|j|t6t4�t4�|j|t4t6�t4�|j|t8t6�t4�|j|t6t8�t4�|j|t4t4�t4�|j|t4t4�t4�|j|dt4�t4�|j;t	j<|t6���|j;t	j<|dt6���|j;t	j<|t6d���|j;t	j<|dt6���|j;t	j<|t6t6���|j;t	j<|t6���t>d!z}td�D]D}|j;t	j@||g|z�|t	j|�z���Ftd�D]=}	tBd|	zz}
|jt	j
d"|
zd|
z�d
|
z��?|j&t(tj
gdgd#z�d$���y#1swY���xYw#1swY���xYw#1swY���xYw)%Nr�r��Fractionr��@g������@rc3�&K�|]	}|dz���y�w)rHNrj)�.0r^s  r�	<genexpr>z&MathTests.testHypot.<locals>.<genexpr>&s����5�q�a��d�5�s�g(@r��*@rfr~�
r�rHr�rjr�r��%��%@r�r�r�r��r皙�����?�string皙����@r�rr�r��rN)"rr�	fractionsryrR�hypotr�r��sqrt�gamma�sinrr4�assertAlmostEqual�sumr�rZr6r�r�r�rSr0�
max_10_exprxr�r�r�r�r�rS�	FLOAT_MAX�isclose�	FLOAT_MIN)r`rryr�r�r#�int_too_big_for_float�	fourthmaxrrD�scales           r�	testHypotzMathTests.testHypots��#�&��
�
���v�v�t�w�w��	�	�#���
�
�3�����#��N���s�4�y��{�#�	�A��"�"��t�B�Q�x� ��	�	�#�5�D��!�H�5�5�6�
�	�	
����t�S�)�4�0�����r�1��r�*�����q�"��t�y�y��|�4�����q�)�C�.�1�4�9�9�Q�<�@�����w�r�{�G�A�J�7��<�����x��B�/��!�R��A�8�B�PR�CS�T�����t�A�w��Q���a��$�q�'�B�D�I�I�a�L�Q�	
����s�C��#�.�����u��t�,������#�&������M�M�#�u�T�{�+�	
�	
����#�s�C� ��#�s�C� �	
��
�
�y�
)�	��A�J�	�
�
�
�y�
)�	&��#�x��%�	&� "�s�~�~�'@�'@�1�'D� E��
�
�
�
�M�:�
;�	,��!�*�+�	,�	
����s��S�)�����q�#���,�����r�3���-�����s�C��#�.�����s�C��#�.�����s�C��#�.�����t�S�)�3�/�����s�D�)�3�/������t�S�)�3�/������t�c�T�*�C�0�����r�C�4��#�.�	
����
�
�5��:�.�/�����
�
�5��C�=�1�2�����
�
�5��b�>�2�3�����
�
�5��S�>�2�3�����
�
�5��c�?�3�4�����
�
�5��:�.�/���O�	��r��	D�A��O�O�D�L�L��)��Q��)@�)2�T�Y�Y�q�\�)A�C�
D�	D�
��9�	D�C���s�
�*�E����T�Z�Z��%���5��9�1�U�7�C�	D�	����)�T�Z�Z�E�C�5��8�E�f�E�Q	�	��	&�	&��	,�	,�s$�6
Z2�Z?�+
[�2Z<�?[	�[z7hypot() loses accuracy on machines with double roundingc	��tj}tj}tjd��}dD]�\}}t
j
|�}t
j
|�}|j||||��5tj|�5t||�dz||�dzzj��}ddd�|j|||��ddd���y#1swY�-xYw#1swY��xYw)N��)�prec))z0x1.10e89518dca48p+29z0x1.1970f7565b7efp+30)z0x1.10106eb4b44a2p+29z0x1.ef0596cdc97f8p+29)z0x1.459c058e20bb7p+30z0x1.993ca009b9178p+29)z0x1.378371ae67c0cp+30z0x1.fbe6619854b4cp+29)z0x1.f4cd0574fb97ap+29z0x1.50fe31669340ep+30)z0x1.494b2cdd3d446p+29z0x1.212a5367b4c7cp+29)z0x1.f84e649f1e46dp+29z0x1.1fa56bef8eec4p+30)z0x1.2e817edd3d6fap+30z0x1.eb0814f1e9602p+29)z0x1.0d3a6e3d04245p+29z0x1.32a62fea52352p+30)z0x1.888e19611bfc5p+29z0x1.52b8e70b24353p+29)z0x1.538816d48a13fp+29z0x1.7967c5ca43e16p+29)z0x1.57b47b7234530p+29z0x1.74e2c7040e772p+29)z0x1.821b685e9b168p+30z0x1.677dc1c1e3dc6p+29)z0x1.9e8247f67097bp+29z0x1.24bd2dc4f4baep+29)z0x1.b73b59e0cb5f9p+29z0x1.da899ab784a97p+28)z0x1.94a8d2842a7cfp+30z0x1.326a51d4d8d8ap+30)z0x1.e930b9cd99035p+29z0x1.5a1030e18dff9p+30)z0x1.1592bbb0e4690p+29z0x1.a9c337b33fb9ap+29)z0x1.1243a50751fd4p+29z0x1.a5a10175622d9p+29)z0x1.57a8596e74722p+30z0x1.42d1af9d04da9p+30)z0x1.ee7dbd9565899p+29z0x1.7ab4d6fc6e4b4p+29)z0x1.5c6bfbec5c4dcp+30z0x1.02511184b4970p+30)z0x1.59dcebba995cap+30z0x1.50ca7e7c38854p+29)z0x1.768cdd94cf5aap+29z0x1.9cfdc5571d38ep+29)z0x1.dcf137d60262ep+29z0x1.1101621990b3ep+30)z0x1.3a2d006e288b0p+30z0x1.e9a240914326cp+29)z0x1.62a32f7f53c61p+29z0x1.47eb6cd72684fp+29)z0x1.d3bcb60748ef2p+29z0x1.3f13c4056312cp+30)z0x1.282bdb82f17f3p+30z0x1.640ba4c4eed3ap+30)z0x1.89d8c423ea0c6p+29z0x1.d35dcfe902bc3p+29)�hx�hyrrqrH)rRr�rr�Contextr:rU�subTest�localcontextr�r�)	r`r�r�high_precisionr�r�rrq�zs	         r�testHypotAccuracyzMathTests.testHypotAccuracyis����
�
���/�/�� ���c�2��$
�*	1�F�B��J�
�
�b�!�A��
�
�b�!�A������a�1��5�
1��)�)�.�9�F��w�q�z�1�}�w�q�z�1�}�<�B�B�D�E�A�F�� � ��q�!��a�0�
1�
1�O*	1�PF�F��
1�
1�s$�>C;�/C/�!C;�/C8�4C;�;D	c��ddlm}ddlm}tj
}tj}|j|dd�d�|j|dd�d�td	�D]�}td
�D]q}td�t|�D��}td�t|�D��}|j|||�|td
�t||�D�����s��|j|gd�gd��d�|j|tgd��tgd���d�|j|dd�d�|j|dd�d�|j|td�dfd�d�|j|dtd�df�d�|j|dtd�fd�d�|j|dd�d�|j||d�|d�f|d�|d�f�|d��|j||dd�|dd�f|dd�|dd�f�|dd��|j|dd�|d ��|j|d!d!�d"�|j|d#d#�d"�|jd$t	jd$|d%d&���|jd$t	jd$|d&d%���|j|d'd(�|d)d(��Gd*�d+t�}	|j||	d�d�d�|j!t"�5|dd,�-�ddd�|j!t"�5|d�ddd�|j!t"�5|dd,d.�ddd�|j!t"�5|dd�ddd�|j!t"�5|d/d�ddd�|j!t$�5|d0d1�ddd�|j!t$�5|dd2�ddd�|j!t"�5|d3d4�ddd�|j!t"�5|d5d6�ddd�d7t&j(j*d
zz}
|j!t$t,f�5|d|
fd8�ddd�|j!t$t,f�5|d8d|
f�ddd�|j!t"�5|d9d�ddd�|j!t"�5|dgd�ddd�Gd:�d;�}|j!t$�5|dg|�g�ddd�td<�D]Q}t/j.�t/j.�}}|j||f|f�t1||z
���St2d=d>d"d?t4t6g}t9j:|d@�A�D]�}t9j:|d@�A�D]�}t||�D�
�cgc]
\}
}|
|z
��}}
}t=t?tj@|��r|j|||�t4��et=t?tjB|��s��|jEt	jB|||�������tFdBz}td�D]�}|f|z}d&|z}|jEt	jH|||�|t	j|�z��|jEt	jH|||�|t	j|�z����td�D]l}tJd |zz}dC|zd@|zf}dD}|jt	j
||�d
|z�|jt	j
||�d
|z��ny#1swY���xYw#1swY���xYw#1swY���xYw#1swY��yxYw#1swY��_xYw#1swY��ExYw#1swY��+xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY��yxYw#1swY��^xYw#1swY��3xYwcc}}
w)ENrrwrx)r�r�r�)r�r�r�r��rrHr�)r�rHr��	r~c3�HK�|]}tjdd����y�w����r~N�rH�uniform�r|�ks  rr}z%MathTests.testDist.<locals>.<genexpr>������B�A�&�.�.��Q�/�B��� "c3�HK�|]}tjdd����y�wr�r�r�s  rr}z%MathTests.testDist.<locals>.<genexpr>�r�r�c3�2K�|]\}}||z
dz���y�w)r�Nrj)r|�px�qxs   rr}z%MathTests.testDist.<locals>.<genexpr>�s����F�&�"�b�b�2�g�#�-�F�s�)�,@r�)r�r�r~)�r)rH���rr�r)�rr�r�r�)rHi����)r�r�rHrj)TTFTF)TFTTFr�)��*@g)@�
�r�rjr�)r�)r�)r�r�r�)rrr)r�r�r�c��eZdZy)�MathTests.testDist.<locals>.TNrnrjrr�Tr��r�rr�)r�r~rm��p�q)rKr�r�)r�r�r�)rrHr�r�)r~rmrK)r�r~rmrK)rrrrrrrrrrrrrrrrrrN)rrrrrrrrrrrrrrrrrr�abc�xyzr�)rHr��rc��eZdZe�Zy)�$MathTests.testDist.<locals>.BadFloatN)rgrhrirvrerjrr�BadFloatr�rrr��r�r�r�r���repeatr�r�)r�r�)&rrr�ryrR�distr�r�r�tupler�r��zip�iterrZr�r�r�rxrSr0r�r�rHr&r�r�r��	itertools�product�any�maprTrSr�r�r�r�)r`�D�Fr�r�r#r]r�r�r�r�r��valuesr�r��diffsr�rrDr�s                    r�testDistzMathTests.testDist�s���(�+��y�y���y�y��	
����o�/?�@�#�F�����i��4�c�:��q��	�A��1�X�
���B��q��B�B���B��q��B�B���&�&���A�J���F�C��1�I�F�F�G��
�	�	
����o�/?�@�#�F�����d�?�3�T�:J�5K�L�c�R�	
����k�;�7��>�����g�w�/��4�����y��~�q�1�7�;�R�@�����g�	�#���';�<�b�A�����r�9�S�>�2�G�<�b�A�����h��0�"�5�����q��u�a��d�m�a��d�A�b�E�]�;�Q�r�U�C�����q��R�y�!�A�r�(�3�a��2�h��"�b�	�5J�K��2�r��	$�����>�>�@��c��	$�
	
����2�2�4��	�	
����b�"��s�+������M�M�#�t�G�V�4�5�	
�	
�����M�M�#�t�F�G�4�5�	
�	
�����)�,���)�,�	
�	��	�����a�	�l�Z�9�3�?��
�
�y�
)�	+��9�	�*�	+�
�
�
�y�
)�	���O�	�
�
�
�y�
)�	2���I�y�1�	2�
�
�
�y�
)�	���A�J�	�
�
�
�y�
)�	2��%�y�1�	2�
�
�
�z�
*�	*���y�)�	*�
�
�
�z�
*�	*���L�)�	*�
�
�
�y�
)�	/��$�g�.�	/�
�
�
�y�
)�	�����	� "�s�~�~�'@�'@�1�'D� E��
�
�
�
�M�:�
;�	5��!�*�+�V�4�	5�
�
�
�
�M�:�
;�	5���!�2�3�4�	5�
�
�
�y�
)�	���q�M�	�
�
�
�y�
)�	��!��a�L�	�	#�	#��
�
�z�
*�	$��!��x�z�l�#�	$��r��	;�A��=�=�?�F�M�M�O�q�A����T�1�$���-�s�1�q�5�z�:�	;�
��t�S�$��S�9���"�"�6�!�4�	<�A��&�&�v�a�8�
<��/2�1�a�y�9�V�R���b��9��9��s�4�:�:�u�-�.��$�$�T�!�Q�Z��5���T�Z�Z��/�0��O�O�D�J�J�t�A�q�z�$:�;�
<�	<���O�	��r��	P�A���q� �A���
�A��O�O�D�L�L��a���Y����1��5M�N�O��O�O�D�L�L��a���Y����1��5M�N�O�		P���9�	7�C���s�
�*�E��5��!�E�'�"�A��A����T�Y�Y�q�!�_�a��g�6����T�Y�Y�q�!�_�a��g�6�	7�y	+�	+��	�	��	2�	2��	�	��	2�	2��	*�	*��	*�	*��	/�	/��	�	��	5�	5��	5�	5��	�	��	�	��	$�	$��:s��:a
�"	a�a$�0
a1�
a>�>
b�%
b�
b%�3
b2�b?�/c�
c�?c&�1c3�d
�
a�a!�$a.�1a;�>b�b�b"�%b/�2b<�?c	�c�c#�&c0�3c=c��|jt�5tjddggd��ddd�y#1swYyxYw)NrrH)r�r�r~)r�rxrRr�rds r�test_math_dist_leakzMathTests.test_math_dist_leak)s7��
�
�
�z�
*�	)��I�I�q�!�f�i�(�	)�	)�	)�s	�:�Ac	���ttd��ttdd��ztdd�D��cgc]}tdd�D]
}d|z|z���c}}zd	d
zddzgz}|D]�}|j|�
�5tj|�}|jt
|�t�|j||z|�|j||dz|dzz�ddd���|jt�5tjd�ddd�tjd�}|jt
|�t�|j|d�tjd�}|jt
|�t�|j|d�Gd�dt�}tj|d��}|jt
|�t�|j|d�|jt�5tj|d��ddd�ddtjd�dddg}|D]P}|j|�
�5|jt �5tj|�ddd�ddd��Rycc}}w#1swY��XxYw#1swY���xYw#1swY��xYw#1swY�@xYw#1swY��xYw)Nr�iX>i(F�<rLi����(rHr�i'r�i�r]rr�TFrc��eZdZd�Zd�Zy)�(MathTests.testIsqrt.<locals>.IntegerLikec��||_yr\r]r_s  rraz1MathTests.testIsqrt.<locals>.IntegerLike.__init__Ls	��"��
rc��|jSr\r]rds rrsz2MathTests.testIsqrt.<locals>.IntegerLike.__index__Os���z�z�!rNrtrjrr�IntegerLiker�Ks��
#�
"rr�i�rr�rzza stringz3.5y@gY@r�)�listrr�rR�isqrt�assertIsr�rQ�assertLessEqual�
assertLessr�rxr��objectrrr�)r`r�r#rYr^r^r��
bad_valuess        r�	testIsqrtzMathTests.testIsqrt.s���
��t����5��|�4�5�
6�!&�r�3��H�A��s�B��H�A�q�!�t�a�x�H�x�H�
I��$�w��D��!�
"�	�!�	4�E����E��*�
4��J�J�u�%���
�
�d�1�g�s�+��$�$�Q�q�S�%�0������!��a��c�{�3�	
4�
4�	4��
�
�z�
*�	��J�J�r�N�	�
�J�J�t����
�
�d�1�g�s�#�����A���J�J�u����
�
�d�1�g�s�#�����A��	"�&�	"�
�J�J�{�4�(�)���
�
�d�1�g�s�#�����B��
�
�
�z�
*�	(��J�J�{�2��'�	(�

��W�_�_�U�3�T��4�
�
� �	&�E����E��*�
&��&�&�y�1�&��J�J�u�%�&�
&�
&�	&��WI�

4�
4��	�	��.	(�	(��&�&��
&�
&�sN� J4�A%J:�K�K�5K,�K �!K,�:K	�K�K� K)�%K,�,K5	c�0�tj}|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d�|j|dd	�d
�|j|d	d�d
�|j|dd
�d�d}d}dD]�}||z}||z}||z|z}|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|�|j|||�|���|j|�d�|j|d�d�|j|d�d�|j|dd	d�d�|j|ddd	�d�|jt|d�|jt|dd	�|jt|dd�|jt|ddd�|j|td�td	��d
�y)Nrrr�rKrbrciYrdreiHrgrhril ,�`aUx�-�xB�:Vn
Ldbl�m�e%Y%l};T^�	)rkl�|/Kr2rli�7rnro)rR�lcmr�r�r�rp)r`r�rrqrrrsrt�ds        r�test_lcmzMathTests.test_lcmcs����h�h������Q���A�&�����Q���A�&�����R���Q�'�����Q���A�&�����Q���Q�'�����Q���A�&�����Q���Q�'�����S�"��s�+�����S�"��s�+�����R����,�����9�8�:�R�	T�
!�� ��(�	-�A��A��A��A��A��A���	�A����S��A�Y��*����S��A�Y��*����S�!��Q�Z��+����S��Q�B�Z��+����S��Q�B�Z��+����S�!��Q�Z��+����S�!��a�R�[�!�,����S�!��a�R�[�!�,�	-�	
������"�����S��3�'�����T��C�(�����S�"�c�*�E�2�����S�!�R��!�,����)�S�%�0����)�S�%��4����)�S�#�t�4����)�S�#�q�$�7�����[��-�{�2��?��Erc	�	�|jttj�|jttjdd�|j	dtjdd�d�|j	dtjdd�d�|j	dtjdd	�d
�|j	dtjd	d�d�|jt
tjd
d�|jt
tjdd�|j
tjd
d�d�|j
tjdd�d�|j
tjtd�t�|j
tjtd�t�|jtjtjtd���dddddzfD�]j}|j
tjt|�t�|j
tjt|�t�|j
tjd
|�d�|j
tjd|�d�|j
tjd|�d�|j
tjd|�d�|jtjtjt|���|jt
tjd
|�|jt
tjd|�|j
tjd|�d�|j
tjd|�d�|j
tjt|�t�|j
tjt|�t�|jtjtjt|�����my)Nr�r�z
ldexp(0,1)rrz
ldexp(1,1)rHzldexp(1,-1)r�r�zldexp(-1,1)rr�r�r�i���r�r��i+���順�d(	� F�x:^Vr�r�)r�r�rRr2r�r�r�r�r�r�rSr��r`rs  r�	testLdexpzMathTests.testLdexp�s������)�T�Z�Z�0����)�T�Z�Z��c�:��
�
�<����A�a��!�4��
�
�<����A�a��!�4��
�
�=�$�*�*�Q�r�"2�C�8��
�
�=�$�*�*�R��"2�B�7����-����R��A����-����S�'�B�������B��1�2�6�������C��2�C�8�������C��,�c�2�������D�$�/��6�����
�
�4�:�:�c�1�#5�6�7�����R��0�	<�A����T�Z�Z��a�R�0�#�6����T�Z�Z��q�b�1�4�8����T�Z�Z��Q�B�/��4����T�Z�Z��a�R�0�#�6����T�Z�Z��Q�B�/��4����T�Z�Z��a�R�0�#�6��O�O�D�J�J�t�z�z�#��r�':�;�<����m�T�Z�Z��Q�?����m�T�Z�Z��a�@����T�Z�Z��A�.��3����T�Z�Z��Q�/��5����T�Z�Z��Q�/��5����T�Z�Z��a�0�$�7��O�O�D�J�J�t�z�z�#�q�'9�:�;�	<rc��|jttj�|jttjddd�|j	dtjdtj
z�d�|j	dtjd�d�|j	dtjtj
�d�|j	d	tjd
d�d�|j	dtjd
dzd
�d�|j	dtjd
dzd�d�|j	dtjd
dz�d�|jttjd�|jttjd
dz�|jttjd
d�|jttjt�|jtjt�t�|jtjtjt���y)NrrHr�zlog(1/e)r�zlog(1)rzlog(e)z	log(32,2)rjr~zlog(10**40, 10)r�r�zlog(10**40, 10**20)r�z
log(10**1000)r�gO�+��@r�r)
r�r�rR�logr�r�rxr�r�r�r�rSr�rds r�testLogzMathTests.testLog�s������)�T�X�X�.����)�T�X�X�q�!�Q�7��
�
�:�t�x�x��$�&�&��1�2�6��
�
�8�T�X�X�a�[�!�,��
�
�8�T�X�X�d�f�f�-�q�1��
�
�;�����A���2��
�
�$�d�h�h�r�2�v�r�&:�B�?��
�
�(�$�(�(�2�r�6�6�*B�A�F��
�
�?�D�H�H�R��X�$6�%�	'����*�d�h�h��5����*�d�h�h��T��	�:����*�d�h�h��C�8����*�d�h�h��5�������#���,�����
�
�4�8�8�C�=�1�2rc	��|jttj�dddzddzfD]C}|j	tj|�tjt|����E|jttjd�|jtjt�t�y)NrH�Zi,r�)	r�r�rR�log1pr�r:rxr�r�r�s  r�	testLog1pzMathTests.testLog1p�s������)�T�Z�Z�0��Q��U�A�s�F�#�	H�A��"�"�4�:�:�a�=�$�*�*�U�1�X�2F�G�	H����*�d�j�j�"�5�������C��#�.rc�,�|jttj�|j	tjd�d�|j	tjd�d�|j	tjd�d�|j	tjddz�d�|j	tjdd	z�d
�|j	tjddz�d�|jt
tjd
�|jt
tjt�|jtjtjt���y)Nrr�rHr�r�r�i�g��@�g�@i�g@�@r�)
r�r�rR�log2r�rxr�r�rSr�rds r�testLog2zMathTests.testLog2�s�����)�T�Y�Y�/�	
������1��s�+�������1��s�+�������1��s�+�	
������1�d�7�+�V�4�������1�d�7�+�V�4�������1�d�7�+�V�4����*�d�i�i��6����*�d�i�i��6�����
�
�4�9�9�S�>�2�3rr�c	��tdd�D�cgc]+}tjtjd|����-}}tdd�D�cgc]
}t	|���}}|j||�ycc}wcc}w)NrEr�r�)rrRr�r2r:r�)r`rr\r(s    r�
testLog2ExactzMathTests.testLog2Exact�si��
:?�u�d�9K�L�A�$�)�)�D�J�J�s�A�.�/�L��L�&+�E�4�&8�9��E�!�H�9��9������*��M��9s�0A6�A;c�@�|jttj�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�|j	d	tjdd
z�d�|jt
tjd�|jt
tjdd
z�|jt
tjt�|jtjt�t�|jtjtjt���y)
Nz
log10(0.1)皙�����?r�zlog10(1)rrz	log10(10)r�zlog10(10**1000)r�g@�@r�)
r�r�rR�log10r�rxr�r�r�r�r�rSr�rds r�	testLog10zMathTests.testLog10�s������)�T�Z�Z�0��
�
�<����C��"�5��
�
�:�t�z�z�!�}�a�0��
�
�;��
�
�2���2��
�
�$�d�j�j��T��&:�F�C����*�d�j�j�$�7����*�d�j�j�2�t�8�)�<����*�d�j�j�$�7�������#���,�����
�
�4�:�:�c�?�3�4rc�d�tj}tj}tj
}|j
|tgd��d�d�|j
|ddgddg�d�|j
|gg�d	�|j
|d
gdg�d
�|j
|dgd
g�d
�dd|d
d�|dd�f|d�|d�fdd|d
d�fd|d
d�fd|d�ffD]�}||f||ddd
�ffD]~\}}|j||��5td�t||d��D��}|||�}|j
||�|j
t|�t|��ddd�����|jt|�|jt|g�|jt|ggg�|jt|ddg�|jt|dgd�|jt|dgdg�|jt|ddgdg�|jt|dgddg�|j
|dgdg�d�|j
|dgdg�d�|j
|dgdg�d�|j
|dgdzdgdz�d�|jt|dd zgdg�|jt|dgdd zg�d!�}	|jt �5|t#d�|	d��ddd�|jt �5||	d�t#d��ddd�d	d"lm}
|j
||
d�dg�d	�|j
|dg|
d��d	�Gd#�d$�}|jt �5|d|�dggd��ddd�|jt �5|gd�d|�dg�ddd�|jt�5|d%d
gddg�ddd�|jt�5|ddgd%d
g�ddd�|j
|d&tj(gd'd(g�tj(�|j
|d&tj(gtj(d(g�tj(�|j
|d&tj(gtj(tj(g�tj(�|j
|d&tj(gd'd(g�tj(�|j+tj,|d&tj(gtj(tj(g���|j+tj,|d&tj.gd'd(g���|j+tj,|d&tj(gtj.d(g���|j+tj,|d&tj(gd)tj.g���d*}|j
||�d+�y#1swY���xYw#1swY���xYw#1swY���xYw#1swY��
xYw#1swY���xYw#1swY���xYw#1swY���xYw),N)r�r�r�r��r��@rzg@g�0@rr�r�)r�g�r�r~r�)rr��r�c3�,K�|]\}}||z���y�wr\rj)r|�p_i�q_is   rr}z(MathTests.testSumProd.<locals>.<genexpr>	s����"T���c�3��9�"T�s�T��strictr�rr�r�r�rr�i���r�l�9Vr�c3�>K�t|�D]}|���t��wr\)r�RuntimeError)rr#s  r�raise_afterz*MathTests.testSumProd.<locals>.raise_after#s$�����1�X�
����
���s�)�BasicIterClassc��eZdZd�Zd�Zy)�*MathTests.testSumProd.<locals>.BadMultiplyc��t�r\�r�r`�others  r�__mul__z2MathTests.testSumProd.<locals>.BadMultiply.__mul__3���"�"rc��t�r\rrs  r�__rmul__z3MathTests.testSumProd.<locals>.BadMultiply.__rmul__5rrN)rgrhrirrrjrr�BadMultiplyr2s��
#�
#rrr�g333333$@g3333334@g�����L>@g�����L4@))r�r�r�)r���r�)rR�sumprodrrr�ryr�r�r�r�r�r�r�r�rxr�rr�test.test_iterr
rr�rSr)
r`rrryr_r�r�r(r\rr
rr�s
             r�testSumProdzMathTests.testSumProd�s;���,�,���/�/���%�%��	
�����l�!3�Y�?��E�����#�s��c�3�Z�8�$�?������R��!�,�����"���t�,�b�1�����"���t�,�b�1�
��
�a��^�X�a��^�,�
�S�\�7�3�<�(��
�(�1�a�.�!�
��!�Q�� �
�����	
�	C�A��Q��!�Q�t��t�W��.�
C���1��\�\�A��\�+�C�"�"T�S��A�d�=S�"T�T�H�$�Q��]�F��$�$�X�v�6��$�$�T�(�^�T�&�\�B�	C�C�
C�	C�$	
���)�W�-����)�W�b�1����)�W�b�"�b�9����)�W�d�R�D�9����)�W�r�d�D�9����)�W�s�e�c�U�;�	
���*�g��B�x�"��>����*�g��t�b�"�X�>�	
����&��A�3�/��8�����!��v�h�/��8�����&��F�8�4�f�=�����%�������
�>��G����-��2�t�8�*�s�e�D����-��3�%�"�d�(��D�	��
�
�|�
,�	/��E�"�I�{�1�~�.�	/�
�
�
�|�
,�	/��K��N�E�"�I�.�	/�	2�������!2�Q�C�8�!�<�����!��n�Q�&7�8�!�<�	#�	#�
�
�
�|�
,�	8��R����+�Y�7�	8�
�
�
�|�
,�	8��I��K�M�2�6�7�	8��
�
�y�
)�	)��U�A�J��B��(�	)�
�
�
�y�
)�	)��Q��G�e�Q�Z�(�	)�	
����$����!1�D�$�<�@�$�(�(�K�����$����!1�D�H�H�d�3C�D�d�h�h�O�����$����!1�D�H�H�d�h�h�3G�H�$�(�(�S�����$����	�!2�T�4�L�A�D�H�H�9�M�����
�
�7�D�$�(�(�+;�t�x�x�i����=R�#S�T�U�����
�
�7�D�$�(�(�+;�d�D�\�#J�K�L�����
�
�7�D�$�(�(�+;�d�h�h��=M�#N�O�P�����
�
�7�D�$�(�(�+;�d�D�H�H�=M�#N�O�P�O������$���-�MC�C��>	/�	/��	/�	/��	8�	8��	8�	8��	)�	)��	)�	)�sU�-A[�#[$�[1�[>�\�\�,\%�[!�$[.�1[;�>\�\�\"�%\/zBsumprod() accuracy not guaranteed on machines with double roundingc�,�tj}|j|dgdzdgdz�d�|j|dgdzddgdz�d�|j|ddgdzdgdz�d�|j|gd�dgd	z�d
�y)Nr�r�rr�r�TF)r�g\�n��Tr�g\�n���r�r�)rRrr�)r`rs  r�test_sumprod_accuracyzMathTests.test_sumprod_accuracyQs���
�,�,������#����a�S��V�4�c�:�����#����d�E�]�R�-?�@�#�F�����$����!3�c�U�R�Z�@�#�F�����!<�s�e�A�g�F��Lr�cpuc�P��tj}tj}tj
}tj}G�fd�dt��G�fd�dt�}d�}d�}ddd	d
ddd
ddzd�d�f
ddddzzdddzzdddzzdddddddzf	dd d!td"�td"�td#�d$d%d&|d'�d(fd)d*|d+�|d,�|d'd-�|d.d/�d0d1d2�d�f
|d3�|d4�|d5�|d6�|d7�|d7�|d#�d8d9f	d:dddzzddd;d<d=d>fd?d@dAdBdCdDdEd�dF�fg	}|D]U}	tdG�D]E}
||	|
�H�D]6}||	|
�H�D]'}||f}
|j||g|
���||g|
���|
��)�8�G�Wy)INc�0��eZdZ�fd�Z�fd�ZeZeZd�Zy)�*MathTests.test_sumprod_stress.<locals>.Intc�>���t|�t|�z�Sr\�rQ�r`r�Ints  �r�__add__z2MathTests.test_sumprod_stress.<locals>.Int.__add__d�����3�t�9�s�5�z�1�2�2rc�>���t|�t|�z�Sr\r%r&s  �rrz2MathTests.test_sumprod_stress.<locals>.Int.__mul__fr)rc� �dt|��d�S)NzInt(�)r%rds r�__repr__z3MathTests.test_sumprod_stress.<locals>.Int.__repr__j����c�$�i�[��*�*rN�rgrhrir(r�__radd__rr-�r's�rr'r#c����
3�
3��H��H�
+rr'c�0��eZdZ�fd�Z�fd�ZeZeZd�Zy)�*MathTests.test_sumprod_stress.<locals>.Fltc�>���t|�t|�z�Sr\r%r&s  �rr(z2MathTests.test_sumprod_stress.<locals>.Flt.__add__nr)rc�>���t|�t|�z�Sr\r%r&s  �rrz2MathTests.test_sumprod_stress.<locals>.Flt.__mul__pr)rc� �dt|��d�S)NzFlt(r,r%rds rr-z3MathTests.test_sumprod_stress.<locals>.Flt.__repr__tr.rNr/r1s�r�Fltr4mr2rr8c�F�d}t||d��D]
\}}|||zz
}�|S)z�This defines the target behavior including expections and special values.
            However, it is subject to rounding errors, so float inputs should be exactly
            representable with only a few bits.
            rTr)r�)r�r�r�rrs     r�baseline_sumprodz7MathTests.test_sumprod_stress.<locals>.baseline_sumprodws8��
�E���1�T�2�
#���S���s��"��
#��Lrc��	||�}dt|�t	|�fS#ttf$r�t$r}t|�ddfcYd}~Sd}~wwxYw)zHMake comparing functions easier. Returns error status, type, and result.N�None)�AssertionError�	NameError�	Exceptionr��repr)�funcr�r'r�s    r�runz*MathTests.test_sumprod_stress.<locals>.run�sZ��
-��t���
��f��t�F�|�3�3��	#�I�.�
���
-��A�w��f�,�,��
-�s��A�
A	�A�	Ar�r�i�llrrrH�Pr�rK)	�@g�g@��&@gy@g�?��?r�g���3�r�r�r�r�i�i:,rDr�g8�r�ig@rr�r�NaNr�r�y@@rr�r�g�z10.5z-2.25r�i�����y@�?�ai���z6.125z12.375z-2.75r�Infrfg+@gp�l�����gp�g`�g�)g<�g��rGg�rEg�g�g`7@TFr~r�r�)rRrr�r�rrr�ryrQr:rr�)r`rr�rryr8r:rB�pools�pool�size�args1�args2r�r's              @r�test_sumprod_stresszMathTests.test_sumprod_stress\s
����,�,���#�#���/�/���%�%��	+�#�	+�	+�%�	+�	�	4���V�U�E�5�%��B���S��V�L�M�
�1�c�6�\�2�a��g�:�r�!�T�'�z�8��U�N�Q��3��
8�
�3��e�E�l�U�5�\�M�5��<���4��R��#�
'�
�E�7�6�?�G�G�,<�h�r�1�o��#�r�"�M�2�s�C��F�
D�
�W�
�w�x�0�'�'�2B�G�A�J����'�%�.��'�%�.�"�d�
L�
�B�q�$�w�J��1�i��Z��
�A�
�E�6�6�4���3�q�6�B�
��"�		�D��a��
��$�T�$�7��E�!(��d�!;��� %�u�~���(�(�� 0�8�4�8���/�$�/� ����
�		rc	�R�����	�
���
����������ddl�ddlm�ddlm�ddlm}ddlm�m	�m
�ddlm�
m
�m�ddlm}|dd	�����fd
���fd��d������
�����f	d
��	��fd��
�	�
fd��d}d�d�|���fd�t#|�D��}|j%|d�y)Nrrx)�starmap)�
namedtuple)r�r�r�)�choicesr�rJ)�median�
DotExample)rrq�target_sumprod�	conditionc
���t�|�}t�|�}t��jt||d����S)NTr)r�r��mulr�)rrq�vec1�vec2ry�operatorrTs    ���r�DotExactzDMathTests.test_sumprod_extended_precision_accuracy.<locals>.DotExact�s:����x��#�D��x��#�D��w�x�|�|�S��t�D�-I�J�K�Krc�z��d�tt|�tt|��zt�||��zS)Nr�)r�r&)rrqr`s  �r�	ConditionzEMathTests.test_sumprod_extended_precision_accuracy.<locals>.Condition�s1�����#�c�1�+�s�3��{�;�;�c�(�1�a�.�>Q�Q�Qrc�`�||z
|dz
z}t|�D�cgc]
}|||zz��c}Scc}w�Nr)r)�lo�hir�widthr#s     r�linspacezDMathTests.test_sumprod_extended_precision_accuracy.<locals>.linspace�s4���"�W��Q��'�E�,1�!�H�5�q�B����N�5�5��5s�+c���	�|dz}dg|z}dg|z}�|�}�
tt|dz��|��}t|dz�dz|d<d|d<|D�cgc]}�dd��|�z��c}|d	||D�cgc]}�dd��|�z��c}|d	|ttt�|dzd||z
���}t||�D]H}�dd��|||z
�z||<�dd��|||z
�z�||�z
||z||<�Jtt||��}	�|	�t|	�\}}�||�||��
||��Scc}wcc}w)
a� Algorithm 6.1 (GenDot) works as follows. The condition number (5.7) of
            the dot product xT y is proportional to the degree of cancellation. In
            order to achieve a prescribed cancellation, we generate the first half of
            the vectors x and y randomly within a large exponent range. This range is
            chosen according to the anticipated condition number. The second half of x
            and y is then constructed choosing xi randomly with decreasing exponent,
            and calculating yi such that some cancellation occurs. Finally, we permute
            the vectors x, y randomly and calculate the achieved condition number.
            rHr�)r�rrr�r�r�N)rrQr�r��roundr�)rrr�n2rrqrtr�r�r#�pairsrbr`rXrVr�rhr�rJr�s          ���������r�GenDotzBMathTests.test_sumprod_extended_precision_accuracy.<locals>.GenDot�s�����a��B����	�A����	�A��Q��A���c�!�A�#�h��2�.�A��q�1�u�:��>�A�a�D��A�b�E�<=�>�q�g�d�C�(�4��7�2�>�A�c�r�F�<=�>�q�g�d�C�(�4��7�2�>�A�c�r�F��S����1��c�A�b�D� 9�:�;�A��2�q�\�
V���t�S�)�D��1�r�6��O�;��!����c�*�T�!�A��F�)�_�<�x��1�~�M�QR�ST�QU�U��!��
V�
��Q���O�E��E�N���;�D�A�q��a��H�Q��N�I�a��O�D�D��?��>s�E�:Ec�p��|\}}}}�t|�|gzt|�dgz�}�||z�Srd)r�)	�res�exrrqrYrZrr`r�s	       ��r�
RelativeErrorzIMathTests.test_sumprod_extended_precision_accuracy.<locals>.RelativeError�sD���.0�+�A�q�.�)���a��S�D�6�)�4��7�a�S�=�9�A���N�*�+�+rc�b���d|�}||j|j�}�||�S)Nr�)rrq)�dotfuncrrrrprormrqs     ��r�TrialzAMathTests.test_sumprod_extended_precision_accuracy.<locals>.Trial�s/�����A��B��"�$�$����%�C� ��b�)�)rr�r�gꌠ9Y>)Fc3�N�K�|]}�tj������y�wr\)rRr)r|r#rtrrrs  ���rr}zEMathTests.test_sumprod_extended_precision_accuracy.<locals>.<genexpr>�s�����N�A�e�D�L�L�!�Q�7�N�s�"%rD)r_r�ryr�rT�collectionsrUrRr�r�r�rHrVr�rJ�
statisticsrWrr�)r`rUrW�times�relative_errrbr`rXryrmrqrtrrrVr�r�rhr�rr_rJrTr�s     @@@@@@@@@@@@@@@@@@r�(test_sumprod_extended_precision_accuracyz2MathTests.test_sumprod_extended_precision_accuracy�s������	�&�%�*�)�)�4�4�%���.W�X�
�	L�
	R�	6�$	E�$	E�L	,�
	*�
�������N��u��N�N������e�,rc�V���jttj��fd�}|dtjd�d�|dtjd�d��j	tjt
�dt
f��j	tjt�d	tf�tjt�}�jtj|d
���jtj|d��y)Nc���||c\}}\}}t||z
�tkDst||z
�r�j|�d|�d|���yyr%r&)r�r'r(�v1�v2�e1�e2r`s       �r�testmodfz$MathTests.testModf.<locals>.testmodfsN���!'���H�R��h�r�2��2�b�5�z�C��3�r�"�u�:��	�	����3�4�$.rz	modf(1.5)r�)r�r�z
modf(-1.5)r�)r�r�r�r�rr)
r�r�rR�modfr�r�r�r�r�rS)r`r��modf_nans`  r�testModfzMathTests.testModf�s�������)�T�Y�Y�/�	4�	��d�i�i��n�j�9���t�y�y����=�������3��#�s��4�������4��4��,�7��9�9�S�>������
�
�8�A�;�/�0�����
�
�8�A�;�/�0rc�%�|jttj�|j	dtjdd�d�|j	dtjdd�d�|j	dtjdd�d�|j	dtjdd�d	�|jtjtd�t�|jtjtd�t�|jtjdt�d
�|jtjdt�d
�|jtjtjtd���|jtjtjdt���|jtjtjdt���|jtjdt�d�|jttjdd�|jtjdt�d�|jtjdd
�d�|jtjdd�d�|jtjdd�d�|jtjdd�d
�|jtjdd�d
�|jttjdd�|jttjdd�|jttjdd�|jtjdt�t�|jtjtjdt���|jtjtt�t�|jtjtd
�t�|jtjtd�t�|jtjtd�t�|jtjtd�d
�|jtjtd�d
�|jtjtd�d�|jtjtd�d�|jtjtd�d�|jtjtt�d�|jtjtjtt���|jtjdt�d�|jtjdd
�d�|jtjdd�d�|jtjdd�d�|jtjdd�d
�|jtjdd�d
�|jttjdd�|jttjdd�|jttjdd�|jtjdt�t�|jtjtjdt���|jtjtt�t�|jtjtd
�t�|jtjtd�t�|jtjtd�t�|jtjtd�d
�|jtjtd�d
�|jtjtd�d�|jtjtd�d�|jtjtd�d�|jtjtt�d�|jtjtjtt���|jtjdt�d
�|jtjdd
�d�|jttjdd�|jtjdd�d
�|jtjdd�d
�|jtjdd�d
�|jtjdd�d
�|jttjdd�|jtjdd�d�|jtjdt�d
�|jtjtjdt���|jtjd
t�d
�|jtjd
d
�d
�|jtjd
d�d
�|jtjd
d�d
�|jtjd
d�d
�|jtjd
d�d
�|jtjd
d�d
�|jtjd
d�d
�|jtjd
d�d
�|jtjd
t�d
�|jtjd
t�d
�|jtjdd�d
�|jtjdd�d
�|jtjtd�d
�|jtjdd�d
�|jtjdd�d
�|jtjtd�d
�|jttjdd�|jttjdd�|jtjdt�d�|jtjdt�d�|jtjdt�t�|jtjdt�t�|jtjdt�t�|jtjdt�t�|jtjdt�d�|jtjdt�d�|jtjdt�t�|jtjdt�t�|jtjdt�d�|jtjdt�d�|jtjdt�d�|jtjdt�d�|jtjdt�t�|jtjdt�t�|j	dtjdd
�d �|j	d!tjdd�d"�|j	d#tjdd
�d�|j	d$tjdd�d
�|j	d%tjdd�d
�|j	d&tjdd�d'�|j	d(tjdd�d)�|j	d*tjdd�d+�|jttjdd'�|jttjdd	�y),Nzpow(0,1)rrzpow(1,0)zpow(2,1)rHz	pow(2,-1)r�r�r�rr�r�r�r�r�g�r�r r�g.�g�������gffffff�?r���������?r�g��������g�������g�������gffffff��z	(-2.)**3.g �z	(-2.)**2.r�z	(-2.)**1.z	(-2.)**0.z
(-2.)**-0.z
(-2.)**-1.r�z
(-2.)**-2.rFz
(-2.)**-3.g��)
r�r�rR�powr�r�r�r�r�rSr�r�rxrds r�testPowzMathTests.testPows�����)�T�X�X�.��
�
�:�t�x�x��!�}�a�0��
�
�:�t�x�x��!�}�a�0��
�
�:�t�x�x��!�}�a�0��
�
�;�����2���4�������#�q�)�3�/�������$��*�D�1����$�(�(�1�c�*�R�0����$�(�(�1�d�+�b�1�����
�
�4�8�8�C��#3�4�5�����
�
�4�8�8�A�s�#3�4�5�����
�
�4�8�8�A�s�#3�4�5�������!�S�)�1�-����-����6�6�B�	
������"�c�*�B�/�������"�b�)�2�.�������"�c�*�B�/�������"�b�)�2�.�������"�b�)�2�.�������"�c�*�B�/����*�d�h�h��C�8����*�d�h�h��D�9����*�d�h�h��C�8�������"�d�+�S�1�����
�
�4�8�8�B��#4�5�6�	
������#�s�+�S�1�������#�r�*�C�0�������#�s�+�S�1�������#�r�*�C�0�������#�r�*�B�/�������#�s�+�R�0�������#�s�+�R�0�������#�t�,�b�1�������#�s�+�R�0�������#�t�,�b�1�����
�
�4�8�8�C��#5�6�7�	
������#�s�+�R�0�������#�r�*�C�0�������#�s�+�R�0�������#�r�*�B�/�������#�r�*�B�/�������#�s�+�R�0����*�d�h�h��S�9����*�d�h�h��T�:����*�d�h�h��S�9�������#�t�,�c�2�����
�
�4�8�8�C��#5�6�7�	
������$��,�c�2�������$��+�T�2�������$��,�c�2�������$��+�S�1�������$��+�R�0�������$��,�b�1�������$��,�b�1�������$��-�r�2�������$��,�c�2�������$��-�r�2�����
�
�4�8�8�D�#�#6�7�8�	
������#�s�+�R�0�������#�r�*�C�0����*�d�h�h��S�9�������#�r�*�B�/�������#�r�*�B�/�������#�s�+�R�0�������#�s�+�R�0����*�d�h�h��T�:�������#�s�+�S�1�������#�t�,�b�1�����
�
�4�8�8�C��#5�6�7�	
������"�c�*�B�/�������"�b�)�2�.�������"�c�*�B�/�������"�b�)�2�.�������"�b�)�2�.�������"�c�*�B�/�������"�c�*�B�/�������"�d�+�R�0�������"�c�*�B�/�������"�d�+�R�0�������"�c�*�B�/�	
������#�r�*�B�/�������$��+�R�0�������#�r�*�B�/�������#�s�+�R�0�������$��,�b�1�������#�s�+�R�0�	
���*�d�h�h��S�9����*�d�h�h��d�;�	
������#�t�,�b�1�������#�t�,�b�1�������#�t�,�c�2�������#�t�,�c�2�������$��-�s�3�������$��-�s�3�������$��-�r�2�������$��-�r�2�	
������#�s�+�S�1�������#�s�+�S�1�������#�s�+�R�0�������#�s�+�R�0�������$��,�b�1�������$��,�b�1�������$��,�c�2�������$��,�c�2�	
�
�
�;�����s� 3�T�:��
�
�;�����s� 3�S�9��
�
�;�����s� 3�T�:��
�
�;�����s� 3�S�9��
�
�<����$��!5�s�;��
�
�<����$��!5�t�<��
�
�<����$��!5�t�<��
�
�<����$��!5�v�>����*�d�h�h��d�;����*�d�h�h��c�:rc���|jttj�|j	dtjd�tj
�|j	dtjd�tj
dz�|j	dtjd�tj
dz�|j	d	tjd
�d
�y)Nzradians(180)�zradians(90)r�rHzradians(-45)i���r�z
radians(0)r)r�r�rR�radiansr�r�rds r�testRadianszMathTests.testRadians�s������)�T�\�\�2��
�
�>�4�<�<��#4�d�g�g�>��
�
�=�$�,�,�r�"2�D�G�G�A�I�>��
�
�>�4�<�<��#4�t�w�w�h�q�j�A��
�
�<����a��!�4rc����ddlm���fd�}gd�}|D]�}�j|��5|j�\}}}tj|�}tj|�}tj|�}	||||	�t
j||�}
�j|
j�|	j��ddd���tjd�}tdd�D]d}|dk(r�	||z}td	�D]I}
|
|z}t
j||�}
||||
�t
j||�}
||||
��K�ftd
ddd
ttfD]T}�jt
jt|���jt
j|t���VdD]V}�jt
j|t�|��jt
j|t�|��Xtd
dd
dtfD]�}�jt �5t
jt|�ddd��jt �5t
jt|�ddd��jt �5t
j|d
�ddd��jt �5t
j|d�ddd���y#1swY��xYw#1swY��xYw#1swY��xYw#1swY�exYw#1swY��xYw)Nrrxc�B���|��|��|�}}}�jt|�t|dz��||z
|z}�j|t|��t|�t|dz�k(r"�j|dzt|dz��yy)z�
            Check that r matches remainder(x, y) according to the IEEE 754
            specification. Assumes that x, y and r are finite and y is nonzero.
            rHN)r�r&r�rQ)	rrq�r�fx�fy�frrryr`s	       ��r�
validate_specz.MathTests.testRemainder.<locals>.validate_spec�s����
"�!��h�q�k�8�A�;�B��B�� � ��R��#�b��d�)�4��b��B��A����Q��A��'��2�w�#�b��d�)�#�� � ��1��c�!�A�#�h�/�$r)0z-4.0 1 -0.0z-3.8 1  0.8z-3.0 1 -0.0z-2.8 1 -0.8z-2.0 1 -0.0z-1.8 1  0.8z-1.0 1 -0.0z-0.8 1 -0.8z-0.0 1 -0.0z 0.0 1  0.0z 0.8 1  0.8z 1.0 1  0.0z 1.8 1 -0.8z 2.0 1  0.0z 2.8 1  0.8z 3.0 1  0.0z 3.8 1 -0.8z 4.0 1  0.0z&0x0.0p+0 0x1.921fb54442d18p+2 0x0.0p+0z?0x1.921fb54442d18p+0 0x1.921fb54442d18p+2  0x1.921fb54442d18p+0z?0x1.921fb54442d17p+1 0x1.921fb54442d18p+2  0x1.921fb54442d17p+1z?0x1.921fb54442d18p+1 0x1.921fb54442d18p+2  0x1.921fb54442d18p+1z?0x1.921fb54442d19p+1 0x1.921fb54442d18p+2 -0x1.921fb54442d17p+1z?0x1.921fb54442d17p+2 0x1.921fb54442d18p+2 -0x0.0000000000001p+2z00x1.921fb54442d18p+2 0x1.921fb54442d18p+2  0x0p0z?0x1.921fb54442d19p+2 0x1.921fb54442d18p+2  0x0.0000000000001p+2z?0x1.2d97c7f3321d1p+3 0x1.921fb54442d18p+2  0x1.921fb54442d14p+1z?0x1.2d97c7f3321d2p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d18p+1z?0x1.2d97c7f3321d3p+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1z?0x1.921fb54442d17p+3 0x1.921fb54442d18p+2 -0x0.0000000000001p+3z00x1.921fb54442d18p+3 0x1.921fb54442d18p+2  0x0p0z?0x1.921fb54442d19p+3 0x1.921fb54442d18p+2  0x0.0000000000001p+3z?0x1.f6a7a2955385dp+3 0x1.921fb54442d18p+2  0x1.921fb54442d14p+1z?0x1.f6a7a2955385ep+3 0x1.921fb54442d18p+2  0x1.921fb54442d18p+1z?0x1.f6a7a2955385fp+3 0x1.921fb54442d18p+2 -0x1.921fb54442d14p+1z?0x1.1475cc9eedf00p+5 0x1.921fb54442d18p+2  0x1.921fb54442d10p+1z?0x1.1475cc9eedf01p+5 0x1.921fb54442d18p+2 -0x1.921fb54442d10p+1z 1  0.c  0.4z-1  0.c -0.4z 1 -0.c  0.4z-1 -0.c -0.4z 1.4  0.c -0.4z-1.4  0.c  0.4z 1.4 -0.c -0.4z-1.4 -0.c  0.4z$0x1.dp+1023 0x1.4p+1023  0x0.9p+1023z$0x1.ep+1023 0x1.4p+1023 -0x0.ap+1023z$0x1.fp+1023 0x1.4p+1023 -0x0.9p+1023)�casez1p-1074i��rr�r�r�r�r�)r�r�r�r�r�)r�ryr�r9r:rUrR�	remainderr��hexrr�r�r��assertIsNaNr�rx)r`r��	testcasesr��x_hex�y_hex�expected_hexrrqr(r\�tinyr�mr^rys`              @r�
testRemainderzMathTests.testRemainder�s����&�
	0� 9
�	�v�
	?�D����4��(�	
?�-1�Z�Z�\�*��u�l��M�M�%�(���M�M�%�(�� �=�=��6���a��H�-�����1�-��� � �����x�|�|�~�>�	
?�	
?�
	?��}�}�Y�'���s�B��		-�A��A�v���D��A��3�Z�
-����H������1�-���a��F�+������A�.���q�b�!�V�,�
-�			-��3��c�4��s�;�	9�E����T�^�^�C��7�8����T�^�^�E�3�7�8�	9�
,�	A�E����T�^�^�E�3�7��?����T�^�^�E�4�8�%�@�	A��D�$��S�#�6�	,�E��"�"�:�.�
+����s�E�*�
+��"�"�:�.�
,����t�U�+�
,��"�"�:�.�
+����u�c�*�
+��"�"�:�.�
,����u�d�+�
,�
,�	,�O	
?�	
?��P
+�
+��
,�
,��
+�
+��
,�
,�s<�B"L�
L �L,�=L8�1M�L	� L)	�,L5	�8M	�M	c��|jttj�|j	dtjd�d�|j	dtjtj
dz�d�|j	dtjtj
dz�d�	|j
tjtjt���|j
tjtjt���|j
tjtjt���y#t$rU|jttjt�|jttjt�Y��wxYw)Nzsin(0)rz	sin(pi/2)rHrz
sin(-pi/2)r�)r�r�rRr�r�r�r�rSr�r�rxr�rds r�testSinzMathTests.testSin0s
�����)�T�X�X�.��
�
�8�T�X�X�a�[�!�,��
�
�;��������� 3�Q�7��
�
�<����4�7�7�(�1�*�!5�r�:�	:��O�O�D�J�J�t�x�x��}�5�6��O�O�D�J�J�t�x�x��~�6�7�	
����
�
�4�8�8�C�=�1�2���	:����j�$�(�(�C�8����j�$�(�(�D�9�	:�s�;A6E-�-AG�
Gc��|jttj�|j	dtjd�d�|j	dtjd�dztj
d�dzz
d�|j	dtjd�tjd�zd�|j
tjt�t�|j
tjt�t�|jtjtjt���y)Nzsinh(0)rzsinh(1)**2-cosh(1)**2rrHr�zsinh(1)+sinh(-1))r�r�rR�sinhr�r�r�r�r�r�rSr�rds r�testSinhzMathTests.testSinh=s������)�T�Y�Y�/��
�
�9�d�i�i��l�A�.��
�
�*�D�I�I�a�L�!�O�D�I�I�a�L�!�O�,K�R�P��
�
�%�t�y�y��|�D�I�I�b�M�'A�1�E�������3���-�������4��$�/�����
�
�4�9�9�S�>�2�3rc���|jttj�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d�|j	dtjd�d	�|j	d
tjd�d�|j	d
tjd�d�|j	dtjd�d�|jtjt�t�|jttjd�|jttjt�|jtjtjt���y)Nzsqrt(0)rr�z	sqrt(2.5)rgS[�:XL�?z
sqrt(0.25)rFr�zsqrt(25.25)g@9@g�)#L�@zsqrt(1)rzsqrt(4)r�rHr�)r�r�rRr�r�r�r�rxr�r�rSr�rds r�testSqrtzMathTests.testSqrtFs"�����)�T�Y�Y�/��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��n�c�2��
�
�;��	�	�#��0B�C��
�
�<����4��#�6��
�
�=�$�)�)�E�"2�4E�F��
�
�9�d�i�i��l�A�.��
�
�9�d�i�i��l�A�.�������3���-����*�d�i�i��4����*�d�i�i��6�����
�
�4�9�9�S�>�2�3rc��|jttj�|j	dtjd�d�|j	dtjtj
dz�d�|j	dtjtj
dz�d�	|j
tjtjt���|j
tjtjt���|j
tjtjt���y#|jttjt�|jttjt�Y��xYw)Nztan(0)rz	tan(pi/4)r�rz
tan(-pi/4)r�)r�r�rR�tanr�r�r�rSr�r�rxr�rds r�testTanzMathTests.testTanTs�����)�T�X�X�.��
�
�8�T�X�X�a�[�!�,��
�
�;��������� 3�Q�7��
�
�<����4�7�7�(�1�*�!5�r�:�	:��O�O�D�J�J�t�x�x��}�5�6��O�O�D�J�J�t�x�x��~�6�7�	
����
�
�4�8�8�C�=�1�2��	:����j�$�(�(�C�8����j�$�(�(�D�9�s�;A6E-�-AGc�X�|jttj�|j	dtjd�d�|j	dtjd�tjd�zdtj
d���|j	dtjt�d�|j	dtjt�d�|jtjtjt���y)	Nztanh(0)rztanh(1)+tanh(-1)rr�r�z	tanh(inf)z
tanh(-inf))r�r�rR�tanhr�r�r�r�r�rSr�rds r�testTanhzMathTests.testTanhas������)�T�Y�Y�/��
�
�9�d�i�i��l�A�.��
�
�%�t�y�y��|�D�I�I�b�M�'A�1��8�8�A�;�	�	(��
�
�;��	�	�#���2��
�
�<����4��"�5�����
�
�4�9�9�S�>�2�3rc���|jtjd�d�|jtjdtjd��tjdd��y)Nr�r�)r�rRr�r�rds r�testTanhSignzMathTests.testTanhSignjsM��	
������3���-�������r�4�9�9�S�>�:����r�3�/�	1rc��|jtjd�d�|jtjd�d�|jttjd��t�|jttjd��t�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd	�d
�Gd�d�}Gd
�dt
�}Gd�d�}Gd�d�}|jtj|��d�|jtj|��d�|j
ttj�|j
ttjdd�|j
ttjtd��|j
ttj|��|j
ttj|��y)Nrr�r�r�g����?g�����g�!��rg-���?Y�i����c��eZdZd�Zy)�'MathTests.test_trunc.<locals>.TestTruncc��y�N�rjrds r�	__trunc__z1MathTests.test_trunc.<locals>.TestTrunc.__trunc__~r�rN�rgrhrir�rjrr�	TestTruncr�}r�rr�c��eZdZd�Zy)�(MathTests.test_trunc.<locals>.FloatTruncc��yr�rjrds rr�z2MathTests.test_trunc.<locals>.FloatTrunc.__trunc__�r�rNr�rjrr�
FloatTruncr��r�rr�c��eZdZy)�)MathTests.test_trunc.<locals>.TestNoTruncNrnrjrr�TestNoTruncr��r�rr�c��eZdZe�Zy)�*MathTests.test_trunc.<locals>.TestBadTruncN)rgrhrirvr�rjrr�TestBadTruncr��rrr�r�rHg�7@)
r�rR�truncr�rQr:r�r�rZrx)r`r�r�r�r�s     r�
test_trunczMathTests.test_truncqs���������A���*�������B���,�����d�j�j��m�,�c�2�����d�j�j��o�.��4�������C��!�,�������D�)�2�.�������H�-�q�1�������I�.��3�������I�.��3�������H�-�t�4�	�	�	��	�	�	�	#�	#�	
������I�K�0�"�5�������J�L�1�2�6����)�T�Z�Z�0����)�T�Z�Z��A�6����)�T�Z�Z��4��A����)�T�Z�Z���?����*�d�j�j�,�.�Arc�2�|jtjd��|jtjd��|jtjd��|jtjd��|jtjt	d���|jtjt	d���|jtjt	d���y)Nr�r�r�r�rrr)r�rR�isfinite�assertFalser:rds r�testIsfinitezMathTests.testIsfinite�s�������
�
�c�*�+�����
�
�d�+�,�����
�
�c�*�+�����
�
�d�+�,�������u�U�|�4�5�������u�U�|�4�5�������u�V�}�5�6rc��|jtjtd���|jtjtd���|jtjtd�dz��|j	tjtd���|j	tjd��|j	tjd��y)Nrz-nanrr�r�)r�rRrSr:r�rds r�	testIsnanzMathTests.testIsnan�s�������
�
�5��<�0�1�����
�
�5��=�1�2�����
�
�5��<�"�#4�5�6�������E�%�L�1�2�������B��(�������B��(rc�2�|jtjtd���|jtjtd���|jtjd��|jtjd��|j	tjtd���|j	tjd��|j	tjd��y)Nrrg�g�rr�r�)r�rRrTr:r�rds r�	testIsinfzMathTests.testIsinf�s�������
�
�5��<�0�1�����
�
�5��=�1�2�����
�
�5�)�*�����
�
�6�*�+�������E�%�L�1�2�������B��(�������B��(rc���|jtjtj��|j	tj
dtj�d�yrP)r�rRrSrr�r�rds r�test_nan_constantzMathTests.test_nan_constant�s:������
�
�4�8�8�,�-�������r�4�8�8�4�b�9rc�N�|jtjtj��|j	tjd�|jtjt
d��|jtjt
d��y)Nr�rr)r�rRrTr�
assertGreaterr�r:rds r�test_inf_constantzMathTests.test_inf_constant�sa������
�
�4�8�8�,�-����4�8�8�S�)�������5��<�0����$�(�(��E�&�M�2rzrequires verbose modec�d�	tjd�}dk7r|jd�	tjd�}|jd�	tjd�}|jd�y#|jd�Y�zxYw#t$rY�KwxYw#t
$rYywxYw)	Ni6e�z6underflowing exp() should not have raised an exceptionrz)underflowing exp() should have returned 0iʚ;z.overflowing exp() didn't trigger OverflowErrorr�z sqrt(-1) didn't raise ValueError)rRrDr�r�r�rx�r`rs  r�test_exceptionszMathTests.test_exceptions�s���	(�����%�A�
��6��I�I�A�B�	H�����$�A�
�I�I�F�G�	:��	�	�$��A�
�I�I�8�9��5	(�
�I�I�'�
(���	��	���	��	�s.�A<�B�B#�<B�	B �B �#	B/�.B/c��dh}d}tjdk(r@tj�d}	tt	t
|j
d���}d}g}tt�D]�\}}}}	}
}}|	dk7s|dk7r�|dvr�|�
|dkr||vr�'tt|�}
d	|vsd
|vrd}
nd|vrd
}
	|
|�}d\}}t|
|||�}|��g|j||||�}|j|���|r$|j!ddj#|�z�yy#t$rY��wxYw#t$rd}Y��t$rd
}Y��wxYw)N�tan0064�darwinr�.�{}: {}({!r}): {}r�)�rect�polar)r�r~�invalid�divide-by-zerorx�overflowr��r~r�zFailures in test_testfile:
  �
  )rS�platform�mac_verr�r�rQr9rxrN�	test_file�getattrrRr�rXr'rVr��join)r`�
SKIP_ON_TIGER�osx_version�version_txtrV�failuresr@rA�ar�ai�er�eirErAr'r*r+rU�msgs                   r�
test_testfilezMathTests.test_testfile�s���#��
����<�<�8�#�"�*�*�,�Q�/�K�
�#�C��[�->�->�s�-C�$D�E��&����-;�I�-F�"	!�)�B��B��B��E��S�y�B�#�I���&�&���&�;��+@���&���4��$�D��E�!�%5��%>�!���u�$�$��
)��b��� &��G�W�"�2�v�w��@�G�����/�/�"�b�"�g�6�C��O�O�C� �E"	!�H��I�I�6��k�k�(�+�,�
-���U�
��
��6�
&�%�� �
)�(��
)�s)�(D!�5D0�!	D-�,D-�0E
�=
E
�	E
c���d}g}tt�D]�\}}}}}tt|�}d|vsd|vrd}nd|vrd}	||�}	d\}
}|dk(rd	}
n$|d
k(rd}n|dk(r|d
k\r|dkrd}
n
|dkrd}
nd}
t
||	|
|�}|��u|j||||�}
|j|
���|r$|jddj|�z�yy#t$rd}	Y��t
$rd}	Y��wxYw)Nr�r�r�rxr�r�r�r�r��lgammagV瞯�<�erfcr�r�r��$@r�r�zFailures in test_mtestfile:
  r�)rF�math_testcasesr�rRrxr�rXr'rVr�r�)r`rVr�r@rArBr(rErAr)r*r+rUr�s              r�test_mtestfilezMathTests.test_mtestfilesE��%����,;�N�,K�8	!�(�B��C��5��4��$�D��E�!�%5��%>�'���u�$�*��
&��3�i�� &��G�W��W�}����x��
 ���v��#��*���9� �G��4�Z�!�G�"�G�"�8�S�'�7�C�G�����/�/�"�b�#�w�7�C��O�O�C� �q8	!�t��I�I�7��k�k�(�+�,�
-���a�
#�"�� �
&�%��
&�s�C�C1�$
C1�0C1c�n�ddlm}tj}|j	|g�d�|j	|gd��d�|j	|tt
dd���d�|j	|ttt
dd����d�|j	|t
dd	�d	��d
�|j	|gd��d�|j	|gd
��d�|j	|gd��d�|j	|gd��d�|j	|d|dd�g�d�Gd�d�}|jt�5|d|�g�ddd�|j	|gd��d�|j	|gd��td��|jt|�|jt|d�|jt|gd��|jt|gd�d��|jt|ddgd��td�td �g}|jt||td���|jt|dgdgdgg�|jt|ddig�|jt|ddigdzddi��|jt|dgdgdggg��|j	|ddgd!��d"�|j	|ddgddg��gd#��|j	|gddi��ddi�|jt�5|d	d$gd�ddd�|j	|gd%��d�|j	|gd&��d�|j	|gd'��d�d7d(�}t
dd)�}|j	||�||��t
d*d+�}|j	||�||��t
d,d-�}|j	||�d�t
dd-�D�cgc]
}t|���}}|j	||�||��t
d,d+�D�cgc]
}t|���}}|j	||�||��t
d,d-�D�cgc]
}t|���}}|j||��|j|dddtd.�ddg��|j|ddtd.�ddg��|j|dtd.�ddg��|j|dtd/�td.�dg��|j|dtd0�td.�dg��|j|dtd.�td/�dg��|j|dtd.�td0�dg��|j	|dddtd/�d1d2g�td0��|j	|dddtd0�d1d2g�td/��|j|dddtd/�d1d2g��|j|dddtd0�d1d2g��|j|dddtd/�d1ddg��|j|dddtd0�d1ddg��|j	t|gd3���t�|j	t|gd4���t�|j	t|t
dd)���t�|j	t|t
dd)�d���t�|j	t|dt!j"d5�dd2dd6g��t j"�y#1swY���xYw#1swY���xYwcc}wcc}wcc}w)8Nrrxrr~)rrHr�i�r�i_7)rrHr�r�r~rd)r�r�r�r�r�rn)rrHr�r�r�)r�r�r�r�r~r�r�r�c��eZdZd�Zy)�(MathTests.test_prod.<locals>.BadMultiplyc��t�r\rrs  rrz1MathTests.test_prod.<locals>.BadMultiply.__rmul__irrN)rgrhrirrjrrrr�hs��
#rrr�)rr�rrr�)r�r�r�rrr�)rsrtrr��a�cr�b�ab�abababababab)rrHrrHrrHrrHrrHrrHr�)rrrHr�)rrrHr�)rrHr�rc��|D]}||z}�	|Sr\rj)r7r�elems   r�_naive_prodz(MathTests.test_prod.<locals>._naive_prod�s�� �
����
��
��Lri'i���r�i���r�rrrr�r�)rrHr�r�r~rm)rr�r�r�r~rmr�rmr�)r�ryrR�prodr�r�rr�r�rr:r��	bytearrayr�r�rQrr)r`r�rrr�rr7rs        r�	test_prodzMathTests.test_prodWs��+��y�y������b��1�%�����b��*�A�.�����d�5��1�:�.�/��6�����d�4��a��
�#3�4�5�t�<�����e�A�r�l�"�5�w�?�����o�.��4�����7�8�%�@�����1�2�E�:�����3�4�e�<�����r�1�Q��7�m�,�c�2�	#�	#��
�
�|�
,�	'��#�{�}�%�&�	'�	
����1�2�E�:�����5�6��e��E����)�T�*����)�T�2�.����)�T�?�;����)�T�?�"��E����)�T�D�$�<�s��C��D�/�9�T�?�3�����)�T�6��3���H����)�T�Q�C�!��q�c�?�;����)�T�Q�q�E�7�3����)�T�Q�q�E�7�1�9�Q�q�E��B����)�T�Q�C�!��q�c�?�"��E�	
����q�!�f�D�1�>�B�����q�!�f�Q��F�3�5Y�Z�����b��A��/�!�A��7�
�
�
�y�
)�	��"�b��1��	�	
����l�+�Q�/�����l�+�Q�/�����l�+�Q�/�	���E�?������h���X�)>�?����$������h���X�)>�?����%������h���+�',�A�t�n�5��E�!�H�5��5�����h���X�)>�?�&+�E�2�&6�7��E�!�H�7��7�����h���X�)>�?�&+�E�4�&8�9��E�!�H�9��9�����h��(�	
����q�!�Q��e��a��;�<�=�����q�!�U�5�\�1�a�8�9�:�����q�%��,��1�5�6�7�����q�%��,��e��Q�?�@�A�����q�%��-��u��a�@�A�B�����q�%��,��e��Q�?�@�A�����q�%��,��f�
�a�@�A�B�����q�!�Q��e��R��:�;�U�6�]�K�����q�!�Q��f�
�b��;�<�e�E�l�K�����q��1�U�5�\�2�q�9�:�;�����q��1�U�6�]�B��:�;�<�����q�!�Q��e��b�!�Q�?�@�A�����q�!�Q��f�
�r�1�a�@�A�B�	
����d�#5�6�7��=�����d�#7�8�9�5�A�����d�5��E�?�3�4�c�:�����d�5��E�?�#�>�?��G�����d�A�w���s�';�Q��1�a�#H�I�J� ���	*�_	'�	'��2	�	��.6��7��9s*�4`�#`�`(�`-�`2�`�`%c�	�tj}tj}td�D]`}|dkrt|dz�n|dkrtd�n
td�D]-}|j	|||�||�|||z
�z��/�btdd�D]I}td|�D]8}|j	|||�||dz
|dz
�|z||dz
|�z��:�Ktdd�D]S}|j	||d�d�|j	||d�|�|j	|||�||���Utd�D]?}|j	||�||��|j	||d�||���A|jt|dd	�|jt|dtjd	��|jt|dd
�|jt|dd�|jt|tjd�d�|jt|dd�|jt|�|jt|ddd
�|jt|�|jt|dd�|jt|ddzd�|jt|dd�|jt|dddz�|j	|dd�d�|j	|dddz�d�ddz}|j	||d�d�|j	||d�|�|j	||d�||dz
z�tjd��r|jt|||�dD]D\}}|j	|||�d�|jt|||��t��F|j	|t!d�t!d��d�|j	|t#d�t#d��d�td
�D]r}|jt|t!d�t!|���t�|jt|t#d�t#|���t��ty)Nr�r�rrLr�r�rr�r��1r��10r�r�rHr�T��cpython�)TT)TF)FFr~)rR�permr�rr�r�r�rrrxr�check_impl_detailr�r�r�rQrmrp)r`rr�rr�s     r�testPermzMathTests.testPerm�s8���y�y���N�N�	��s��	C�A�&'�#�g�e�A��E�l��C��5��9�U�SU�Y�
C��� � ��a���!*�1���1�q�5�1A�!A�C�
C�	C��q�#��	V�A��1�a�[�
V��� � ��a���T�!�a�%��Q��-?�!�-C�d�1�q�5�RS�n�-T�U�
V�	V�
�q�#��	7�A����T�!�Q�Z��+����T�!�Q�Z��+����T�!�Q�Z��1��6�	7��r��	:�A����T�!�W�i��l�3����T�!�T�]�I�a�L�9�	:�	
���)�T�2�s�3����)�T�2�w���s�/C�D����)�T�2�s�3����)�T�4��3����)�T�7�?�?�4�+@�!�D����)�T�4��3����)�T�*����)�T�2�q�!�4����)�T�*�	
���*�d�B��2����*�d�Q��W�H�a�8����*�d�A�r�2����*�d�A��4��x�8�	
����a���Q�'�����a��D��)�1�-�
�t�G������a���Q�'�����a���Q�'�����a���Q�!�A�#�Y�/��$�$�T�2����m�T�1�a�8�?�	1�D�A�q����T�!�Q�Z��+��M�M�$�t�A�q�z�*�C�0�	1�	
����k�!�n�k�!�n�=�r�B�����k�!�n�k�!�n�=�r�B��q��	K�A��M�M�$�t�K��N�K��N�C�D�c�J��M�M�$�t�K��N�K��N�C�D�c�J�	Krc�
�tj}tj}td�D]i}|dkrt|dz�n|dkrtd�n
td�D]6}|j	|||�||�||�|||z
�zz��8�ktdd�D]F}td|�D]5}|j	|||�||dz
|dz
�||dz
|�z��7�Htd�D]4}|j	||d�d�|j	|||�d��6tdd�D]7}|j	||d�|�|j	|||dz
�|��9td�D]8}t|dz�D]%}|j	|||�||||z
���'�:|jt|dd	�|jt|dtjd	��|jt|dd
�|jt|dd�|jt|tjd�d�|jt|dd�|jt|d�|jt|ddd
�|jt|�|jt|dd�|jt|ddzd�|jt|dd�|jt|dddz�|j	|dd�d�|j	|dddz�d�ddz}|j	||d�d�|j	||d�|�|j	||d�||dz
zdz�|j	|||�d�|j	|||dz
�|�|j	|||dz
�||dz
zdz�tjd��r|jt|||dz�dD]D\}}|j	|||�d�|jt|||��t��F|j	|t!d�t!d��d�|j	|t#d�t#d��d�td
�D]r}|jt|t!d�t!|���t�|jt|t#d�t#|���t��ty)Nr�r�rrLr�r�rrHr�rr�rr�r�r�Trr
r~)rR�combr�rr�r�r�rrrxrrr�r�r�rQrmrp)r`rr�rr�s     r�testCombzMathTests.testComb�s����y�y���N�N�	��s��	:�A�&'�#�g�e�A��E�l��C��5��9�U�SU�Y�
:��� � ��a���Y�q�\�!�!��y��Q��'7�7�.9�:�
:�	:��q�#��	R�A��1�a�[�
R��� � ��a���T�!�a�%��Q��-?�$�q�1�u�a�.�-P�Q�
R�	R�
�s��	,�A����T�!�Q�Z��+����T�!�Q�Z��+�	,��q�#��	0�A����T�!�Q�Z��+����T�!�Q��U�^�Q�/�	0�
�s��	=�A��1��6�]�
=��� � ��a���T�!�Q��U�^�<�
=�	=�	
���)�T�2�s�3����)�T�2�w���s�/C�D����)�T�2�s�3����)�T�4��3����)�T�7�?�?�4�+@�!�D����)�T�4��3����)�T�2�.����)�T�2�q�!�4����)�T�*�	
���*�d�B��2����*�d�Q��W�H�a�8����*�d�A�r�2����*�d�A��4��x�8�	
����a���Q�'�����a��D��)�1�-�
�t�G������a���Q�'�����a���Q�'�����a���Q�!�A�#�Y�!�^�4�����a���Q�'�����a��1���q�)�����a��1���q�A�a�C�y�A�~�6��$�$�T�2����m�T�1�a��d�;�?�	1�D�A�q����T�!�Q�Z��+��M�M�$�t�A�q�z�*�C�0�	1�	
����k�!�n�k�!�n�=�r�B�����k�!�n�k�!�n�=�r�B��q��	K�A��M�M�$�t�K��N�K��N�C�D�c�J��M�M�$�t�K��N�K��N�C�D�c�J�	Krc��|jtjdt�d�|jtjdt�d�|jtjdd�d�|jtjdd�d�|jtjd	t�tjd
��|jtjd	t�tjd��|jtjd	td�
�tjd
��|jtjd	td�
�tjd��|jtjd	td�
�tjd��|jtjd	td�
�tjd��t
dd�D]z}|jtjdd|�
�d�|jtjdd|�
�d�|jtjdd|�
�d��|tjjtjjz}|jtjdt�|�|jtjdt�|�|jtjdt�|�|jtjdt�|�|jtj|d�d�|jtj|d�d�|jtj|d�d�|jtj|d�d�tjj}|jtjtd�|�|jtjtd�|�|jtj|t�t�|jtj|t�t�|jtjtd	��|jtjd	t��|jtjtt��|jd	tjd	td�
��|jt �5tjd	td�
�ddd�y#1swYyxYw)Ng0Cg������/Cg0Cg�Cr�g�������Cg��g��������r�z0x1.fffffffffffffp-1z0x1.0000000000001p+0r)�stepsr�z0x1.ffffffffffffdp-1z0x1.0000000000003p+0r~r�r�rr�)r�rR�	nextafterr�r:rUr�assertEqualSignrSr0�min�epsilonr3r�r�r�rx)r`r�smallest_subnormal�largest_normals    r�test_nextafterzMathTests.test_nextafterC	s-��	
������(:�S�D�A�+�	-�������(:�C�@�+�	-�������(=�s�C�.�	0�������(>��D�/�	1�	
�������c�T�2����'=�>�	@��������S�1����'=�>�	@��������c�T��;����'=�>�	@��������S��:����'=�>�	@��������c�T��;����'=�>�	@��������S��:����'=�>�	@��1�a�[�	P�E����T�^�^�C��E�B�C�H�� � �����d�%�!H�$�O�� � �����d�%�!H�$�O�	P�!�^�^�/�/�#�.�.�2H�2H�H���������c�2�4F�G��������c�2�4F�G��������s�d�3�6H�5H�I��������s�d�3�6H�5H�I����T�^�^�,>��E�t�L����T�^�^�-?�,?��F��M����T�^�^�,>��E�t�L����T�^�^�-?�,?��F��M����+�+���������S�1�>�B���������c�2�^�O�D���������<�c�B���������#��>���E�	
�������S�1�2��������S�1�2��������S�1�2�����d�n�n�S�#�Q�?�@�
�
�
�z�
*�	/��N�N�3��2�.�	/�	/�	/�s�.W�Wc�D�|jtjd�tjj
�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�tjjtjj
z�|jtjt�ttjtt�z
�|jtjt�t�|jtjtj��ddddtfD]V}|j|��5|jtj|�tj|��ddd��Xy#1swY�cxYw)	Nr�l�lr�lg�@r�r�)
r�rRr�rSr0rrr�rr�r�rr�r�s  r�test_ulpzMathTests.test_ulp	sp��������#�����(>�(>�?�������'�*�C�0�������'�*�C�0�������'�*�F�3�	
������#�����+�+�c�n�n�.D�.D�D�	F�������)�,�"�T�^�^�I��t�%D�D�	F�	
������#���,�������$�(�(�+�,��s�G�W�c�2�	<�A������"�
<�� � ����1�"��t�x�x��{�;�
<�
<�	<�
<�
<�s�:H�H	c�,�Gd�d�}tjtjtjfD]L}|�}|j	t
�5|d|�ddd�|j
t|dd���Ny#1swY�(xYw)Nc��eZdZd�Zy)�$MathTests.test_issue39871.<locals>.Fc��d|_ddzy)NTrr)�	convertedrds rrez.MathTests.test_issue39871.<locals>.F.__float__�	s��!%����!�rN)rgrhrirerjrrr�r�	s��
rr�znot a numberr F)rRr�r�r�r�r�r�r�)r`r�rArqs    r�test_issue39871zMathTests.test_issue39871�	s}��	�	��J�J��
�
�t�~�~�=�	=�D���A��"�"�9�-�
(��^�Q�'�
(�

���W�Q��U�;�<�	=�
(�
(�s�
B
�
B	c���|jttjd�|jttjd�|jttj
dd�|jttj
dd�|jttj
d�|jttj
ddd�y)NrNr�r�r�)r�r�rRrD�erfr�rds r�test_input_exceptionszMathTests.test_input_exceptions�	s������)�T�X�X�v�6����)�T�X�X�v�6����)�T�Z�Z���=����)�T�Z�Z��f�=����)�T�Z�Z��5����)�T�Z�Z��c�3�?rc�p�tj|�s!|jdj|��yy)NzExpected a NaN, got {!r}.)rRrSr�r'r_s  rr�zMathTests.assertIsNaN�	s+���z�z�%� ��I�I�1�8�8��?�@�!rc��|j||�|jtjd|�tjd|��y)zSimilar to assertEqual(), but compare also the sign with copysign().

        Function useful to compare signed zeros.
        r�N)r�rRr�)r`rrqs   rrzMathTests.assertEqualSign�	s:��
	
����A��������s�A�.��
�
�c�1�0E�FrNr�)Vrgrhrir�r�r�r�r�r�r�r�r�r�r�rr�r��unittest�skipIfrSr��machiner�r�r�r�r�r�rr�cpython_onlyrrr"r.�HAVE_DOUBLE_ROUNDINGr`rur�r�r�r�r�r�r�r�r�r��requires_mac_verr�rrr�requires_resourcerRrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
skipUnlessrr�r�r�rr
rrrr!r$r�rrjrrr}r}�s���6�.�	4�5�	4�5�4�	5�<:�|4� %;�N�:��:�B3��X�_�_�S�\�\�W�,�W�1A��1A�1A�1C�GW�1W�[�]�4�]�4�5�<�	=�/�@�:�
���<��<�#<�J;�.8�$��X�_�_�)�M�O�mD�O��mD�^(E�TMF�^��X�_�_�)�N�P�:1�P��:1�x7�B)�
3&�j*F�X<�B3�$/��4��4�"��W���b�!�$�+�%��+�
5�^.�B��X�_�_�)�]�_����M��_��M��W���u�%�H�&�H�T��X�_�_�)�]�_�����W���u�%�Q-�&��_��
Q-�f1�&H;�l5��~,��~,�@3�4�4�3�4��1��1�B�@7�)�)�:�
3��X����"9�:�:�;�:�>�6-��6-�p�@-��@-�Dd*�L>K�@DK�L�8/��8/�v�<��<�,=� @�A�Grr}c�~�eZdZejZd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zy)�IsCloseTestsc�`�|j|j||g|��i|��|�d|�d���y)N� and z should be close!�r�)r�r��r`rsrtr��kwargss     r�
assertIsClosezIsCloseTests.assertIsClose�	s5���������Q��;�D�;�F�;�<=�q�A�	�	Crc�`�|j|j||g|��i|��|�d|�d���y)Nr2z should not be close!r3)r�r�r4s     r�assertIsNotClosezIsCloseTests.assertIsNotClose�	s7���������a��<�T�<�V�<�AB�A�F�	�	Hrc�F�|D]\}}|j||g|��i|���yr\)r6�r`�examplesr�r5rsrts      r�assertAllClosezIsCloseTests.assertAllClose�	s1���	6�D�A�q��D���q�!�5�d�5�f�5�	6rc�F�|D]\}}|j||g|��i|���yr\)r8r:s      r�assertAllNotClosezIsCloseTests.assertAllNotClose�	s1���	9�D�A�q�!�D�!�!�!�Q�8��8��8�	9rc��|jt�5|jddd��ddd�|jt�5|jdddd��ddd�y#1swY�=xYw#1swYyxYw)Nrg0��.�+���rel_tolr?g _�©rAr+)r�rxr6rds r�test_negative_tolerancesz%IsCloseTests.test_negative_tolerances�	s~��
�
�
�z�
*�	6����q�!�W��5�	6�
�
�
�z�
*�	D����q�!�V�U��C�	D�	D�	6�	6��	D�	D�s�A'�A3�'A0�3A<c�4�gd�}|j|dd��y)N))r�r�)�N���@irE)�;���rF)i90g��@)r�r�)�NFrGr�rB�r<)r`�identical_exampless  r�test_identicalzIsCloseTests.test_identical�	s"��0��	
���.��S��Irc�X�gd�}|j|d��|j|d��y)N))g�חAg�חA)g:�0�yE�g��n�yE�)g�	ѭ��?gfN�ӭ��?�:�0�yE>r@��&�.>�r<r>)r`�eight_decimal_places_exampless  r�test_eight_decimal_placesz&IsCloseTests.test_eight_decimal_places�	s5��)C�%�	
���9�4��H����<�d��Krc�X�gd�}|j|d��|j|d��y)N))rMr�)g��&�.�r�)gu�?j�/ʠr�r�r@rLr�)r>r<)r`�near_zero_exampless  r�test_near_zerozIsCloseTests.test_near_zero�	s4��.��	
���1�3��?����.���=rc���|jtt�|jttd��|jtt�|jttd��y)Nr�r�)r6r�r�rds r�test_identical_infinitez$IsCloseTests.test_identical_infinite�	sL�����3��$����3��S��1����4��&����4��s��3rc���ttftdfdtfttfttfttftdfdtftdfdtfg
}|j|d��y)Nr?r�rMg�������?r�)r�r�r�r>)r`�not_close_exampless  r�test_inf_ninf_nanzIsCloseTests.test_inf_ninf_nan�	sg��"�C�j�"�F�m�%�s�m�"�C�j�"�C�j�"�D�k�"�C�j�"�C�j�"�E�l�$�c�l�	,��	
���1�;L��Mrc�`�gd�}|j|d��gd�}|j|d��y)N))r�r�)�333333�rZ)�Y��n��r[r�r@))r�g�?)g�������?r�)gZb���tigTb���tirN)r`�zero_tolerance_close_examples�!zero_tolerance_not_close_exampless   r�test_zero_tolerancez IsCloseTests.test_zero_tolerance	
s?��)=�%�	
���9�3��G�-N�)�	
���@�#��Nrc�.�|jddgd��y)N)r�r�)r�r�r�r@rHrds r�test_asymmetryzIsCloseTests.test_asymmetry
s�����W�g�.���<rc�X�ddg}|j|d��|j|d��y)N)����)i�[i�[rLr@rMrN)r`�integer_exampless  r�
test_integerszIsCloseTests.test_integers
s:��2�2�4��	
���,�d��;����/���>rc���ddlm}|d�|d�f|d�|d�f|d�|d�f|d	�|d
�fg}|j|d��|j|d
��y)Nrrwz
1.00000001z1.0z1.00000001e-20z1.0e-20z1.00000001e-100z1.0e-100z
1.00000001e20z1.0e20rLr@rM)rrr<r>)r`r�decimal_exampless   r�
test_decimalszIsCloseTests.test_decimals!
s���#�$�\�2�G�E�N�C�$�%5�6��	�8J�K�$�%6�7���9L�M�$�_�5�w�x�7H�I�K��	
���,�d��;����/���>rc���ddlm}|dd�dz|d�f|d�|d�f|dd�|dd�fg}|j|d�	�|j|d
�	�y)Nrrxrrcrbl �	(q�e�	r�rLr@rM)r�ryr<r>)r`ry�fraction_exampless   r�test_fractionszIsCloseTests.test_fractions,
sz��&��a��
#�a�
'��!��5�
�i�
 �(�9�"5�6�
�i��
(�(�1�f�*=�>�@��	
���-�t��<����0�$��?rN)rgrhrirRr�r6r8r<r>rCrJrPrSrUrXr^r`rerhrkrjrrr0r0�	s^���l�l�G�C�H�6�9�D�J�L�>�4�
N�
O�=�?�	?�	@rr0c�@�ddlm}|j|d��|S)Nr)�DocFileSuitezieee754.txt)�doctestrm�addTest)�loader�tests�patternrms    r�
load_testsrs8
s��$�	�M�M�,�}�-�.��Lrr�):�test.supportrr�testrr'r�r�rrR�osr�rHrrSr�r:r�r�r�r0r3r�rr�rrqr+rg�argv�file�__file__�path�dirname�curdir�test_dirr�r�r�rrrr$r/rFrNrXrZrQrmr�rprv�TestCaser}r0rs�mainrjrr�<module>r�s���4�������	��
�
�
����E�l���E�l���V�}���N�N���	��N�N���	����1��A���)���z���8�8�A�;�D��D�
�7�7�?�?�4� �-�B�I�I�������h�(<�=���G�G�L�L��#8�9�	�
�L5�H�	,�B�$:�4�0+�Z��	�#�	��&����H#G��!�!�H#G�VFx@�8�$�$�x@�v�
�z���H�M�M�O�r