Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_math.cpython-38.pyc
U

>��g�H�@s�ddlmZmZmZddlmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZdZed�Zed�Zed�ZejjZejjZd\ZZeed	kZed
kr�ejdZneZe
j �!e�p�e
j"Z#e
j �$e#d�Z%e
j �$e#d�Z&d
d�Z'dd�Z(dd�Z)dd�Z*dd�Z+dd�Z,dd�Z-dd�Z.d+dd �Z/Gd!d"�d"e0�Z1Gd#d$�d$e2�Z3Gd%d&�d&ej4�Z5Gd'd(�d(ej4�Z6d)d*�Z7ed
k�r�e7�dS),�)�run_unittest�verbose�requires_IEEE_754)�supportNg�h㈵��>�nan�inf�-inf)���7y�ACg�):��@g��7y�AC�__main__zmath_testcases.txtzcmath_testcases.txtcCs.t�dt�d|��d}|dkr*|d}|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.
    �<q�<drl)�struct�unpack�pack)�x�n�r�-/opt/cppython/lib/python3.8/test/test_math.py�to_ulps's
rcCs�tt|��}t�|�s t�|�r$|St�dt�d|��d}t�dt�d|d��d}t�|�r�t�dt�d|d��d}||S||SdS)a�Return the value of the least significant bit of a
    float x, such that the first float bigger than x is x+ulp(x).
    Then, given an expected result x and a tolerance of n ulps,
    the result y should be such that abs(y-x) <= n * ulp(x).
    The results from this function will only make sense on platforms
    where native doubles are represented in IEEE 754 binary64 format.
    rrr�N)�abs�float�math�isnan�isinfr
rr)rrZx_nextZx_prevrrr�ulp8s
rcCs|rdt||d@�SdS)zANumber of '1' bits in binary expansion of a nonnnegative integer.rr)�count_set_bits)rrrrresrcCsD||d?}|sdS|dkr |S||dB}t||�t||�SdS)z�Product of integers in range(start, stop, 2), computed recursively.
    start and stop should both be odd, with start <= stop.

    rN)�partial_product)�start�stopZ
numfactorsZmidrrrrisrcCs`d}}tt|����D]6}|t||d?ddB||?ddB�9}||9}q||t|�>S)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�innerZouter�irrr�py_factorialws
*
r%cCsLtt|�t|��}t||�}||ks0||kr4dSd}|�||||�SdS)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)rr�format)�expected�got�ulp_tol�abs_tolZ	ulp_errorZ	abs_error�fmtrrr�
ulp_abs_check�sr,c	cs�t|���}|D]x}d|kr,|d|�d��}|��s6q|�d�\}}|��\}}}|��}|d}	|dd�}
||t|�t|	�|
fVqW5QRXdS)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]*

    �--N�->rr)�open�index�strip�splitr)�fname�fp�line�lhs�rhs�id�fn�arg�
rhs_pieces�exp�flagsrrr�parse_mtestfile�s	
r>c
	cs�t|���}|D]�}|�d�s|��s&q|�d�\}}|��\}}}}|��}	|	d|	d}
}|	dd�}||t|�t|�t|
�t|�|fVqW5QRXdS)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
    r-r.rr�N)r/�
startswithr1r2r)
r3r4r5r6r7r8r9Zarg_realZarg_imagr;Zexp_realZexp_imagr=rrr�parse_testfile�s 
�rA��cCs�||krdSd}t|t�r.t|t�r.t|�}nt|t�rJt|t�rJt|�}t|t�r�t|t�r�t�|�rxt�|�rxd}n$t�|�s�t�|�r�nt||||�}|dk	r�d}|�||�}|d�|�7}|SdSdS)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�intrrrr,r&)r'r(r)r*�failure�fail_fmtZfail_msgrrr�result_check�s&
rHc@seZdZdS)�IntSubclassN��__name__�
__module__�__qualname__rrrrrI�srIc@seZdZdd�Zdd�ZdS)�MyIndexablecCs
||_dS�N��value��selfrQrrr�__init__�szMyIndexable.__init__cCs|jSrOrP�rSrrr�	__index__�szMyIndexable.__index__N�rKrLrMrTrVrrrrrN�srNc@s(eZdZdydd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zejd'd(��Zd)d*�Zd+d,�Zd-d.�Ze
e�ed/�d0d1���Zd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&e
d@dA��Z'e
e�(dBd�dCdD���Z)dEdF�Z*dGdH�Z+dIdJ�Z,dKdL�Z-e
dMdN��Z.dOdP�Z/dQdR�Z0dSdT�Z1dUdV�Z2dWdX�Z3e
dYdZ��Z4d[d\�Z5d]d^�Z6d_d`�Z7dadb�Z8e
dcdd��Z9e
dedf��Z:e�;e<dg�dhdi��Z=e
djdk��Z>e
dldm��Z?dndo�Z@dpdq�ZAdrds�ZBdtdu�ZCdvdw�ZDdxS)z�	MathTestsrBrCcCs,t||||�}|dk	r(|�d�||��dS)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{}: {})rH�failr&)rS�namer(r'r)r*rFrrr�ftests	zMathTests.ftestcCs8|�dtjd�|�dtjd�|�tjdtj�dS)N�pig-DT�!	@�egiW�
�@r?)r[rr\r]�assertEqual�taurUrrr�
testConstants
szMathTests.testConstantscCs�|�ttj�|�dt�d�tj�|�dt�d�tjd�|�dt�d�d�|�ttjt�|�ttjt�|�ttjdt	�|�ttjdt	�|�
t�t�t���dS)Nzacos(-1)���zacos(0)rr?zacos(1)r)
�assertRaises�	TypeErrorr�acosr[r\�
ValueError�INF�NINF�eps�
assertTruer�NANrUrrr�testAcosszMathTests.testAcoscCs�|�ttj�|�dt�d�d�|�dt�d�d�|�ttjd�|�ttjd�|�t�t�t�|�ttjt�|�	t�
t�t���dS)Nzacosh(1)rrzacosh(2)r?g5�qB�?ra)rbrcr�acoshr[rer^rfrgrirrjrUrrr�	testAcoshszMathTests.testAcoshcCs�|�ttj�|�dt�d�tjd�|�dt�d�d�|�dt�d�tjd�|�ttjt�|�ttjt�|�ttjdt	�|�ttjdt	�|�
t�t�t���dS)Nzasin(-1)rar?zasin(0)rzasin(1)r)
rbrcr�asinr[r\rerfrgrhrirrjrUrrr�testAsin(szMathTests.testAsincCs�|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�|�t�t�t�|�t�t�t�|�t�	t�t
���dS)	Nzasinh(0)rzasinh(1)rg'�ya64�?z	asinh(-1)rag'�ya64�)rbrcr�asinhr[r^rfrgrirrjrUrrr�	testAsinh3szMathTests.testAsinhcCs�|�ttj�|�dt�d�tjd�|�dt�d�d�|�dt�d�tjd�|�dt�t�tjd	�|�d
t�t�tjd	�|�t�	t�t
���dS)Nzatan(-1)ra�zatan(0)rzatan(1)rz	atan(inf)r?z
atan(-inf))rbrcr�atanr[r\rfrgrirrjrUrrr�testAtan<szMathTests.testAtancCs�|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�|�ttjd	�|�ttjd
�|�ttjt�|�ttjt�|�	t�
t�t���dS)Nzatanh(0)rz
atanh(0.5)��?g�z��?zatanh(-0.5)��g�z��rra)rbrcrrsr[�atanhrerfrgrirrjrUrrr�	testAtanhEszMathTests.testAtanhcCs|�ttj�|�dt�dd�tjd�|�dt�dd�tjd�|�dt�dd�d�|�d	t�dd�tjd�|�d
t�dd�tjd�|�dt�dt�tj�|�d
t�dd�tj�|�dt�dd�tj�|�t�dd�d�|�t�dd�d�|�t�dt�d�|�	t�
t�dt���|�dt�dt�tj�|�dt�dd�tj�|�dt�dd�tj�|�t�dd�d�|�t�dd�d�|�t�dt�d�|�	t�
t�dt���|�dt�tt�tjdd�|�dt�td�tjd�|�dt�td�tjd�|�dt�td�tjd�|�dt�td�tjd�|�dt�tt�tjd�|�	t�
t�tt���|�dt�tt�tjdd�|�dt�td�tjd�|�dt�td�tjd�|�dt�td�tjd�|�d t�td�tjd�|�d!t�tt�tjd�|�	t�
t�tt���|�d"t�dt�tj�|�d#t�dd�tjd�|�d$t�dd�tjd�|�t�dt�d�|�	t�
t�dt���|�d%t�dt�tj�|�d&t�dd�tjd�|�d't�dd�tjd�|�t�dt�d�|�	t�
t�dt���|�	t�
t�tt���|�	t�
t�td���|�	t�
t�td���|�	t�
t�td���|�	t�
t�td���|�	t�
t�tt���|�	t�
t�tt���dS)(Nzatan2(-1, 0)rarr?zatan2(-1, 1)rrrzatan2(0, 1)zatan2(1, 1)zatan2(1, 0)zatan2(0., -inf)rCzatan2(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.))rbrcr�atan2r[r\rgr^rfrirrjrUrrr�	testAtan2Psf "zMathTests.testAtan2cCs|�ttj�|�ttt�d���|�dt�d�d�|�dt�d�d�|�dt�d�d�|�d	t�d
�d�|�dt�d
�d�|�dt�d�d�Gdd�d�}Gdd�d�}|�dt�|��d�|�ttj|��|�}dd�|_|�ttj|�|�ttj|d�dS)Nruz	ceil(0.5)rz	ceil(1.0)��?z	ceil(1.5)��?r?z
ceil(-0.5)rvrz
ceil(-1.0)��raz
ceil(-1.5)���c@seZdZdd�ZdS)z$MathTests.testCeil.<locals>.TestCeilcSsdS�N�*rrUrrr�__ceil__�sz-MathTests.testCeil.<locals>.TestCeil.__ceil__N)rKrLrMr�rrrr�TestCeil�sr�c@seZdZdS)z&MathTests.testCeil.<locals>.TestNoCeilNrJrrrr�
TestNoCeil�sr�zceil(TestCeil())r�cWs|SrOr��argsrrr�<lambda>��z$MathTests.testCeil.<locals>.<lambda>)	rbrcr�ceilr^rE�typer[r�)rSr�r��trrr�testCeil�s 
zMathTests.testCeilcCs�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�d	d
�d�|�ttj�|�t�dd�d�|�t�dd
�d�|�t�td�t�|�t�td
�t�|�t�td�t�|�t�td
�t�|�t�dt�d�|�t�dt�d�|�t�tt�t�|�t�tt�t�|�t�tt�t�|�t�tt�t�|�t�t�t	d���|�t�t�t	t���|�t�t�t	t���|�t�t�t	t	���|�t�
t�tt	���|�tt�dt	��d�dS)
Nrr�rrCi���r�r|�@�@rz���@)r^r�copysignrbrcrfrgrirrjrrrUrrr�testCopysign�s0zMathTests.testCopysigncCs�|�ttj�|jdt�tjd�dtd�d�|�dt�d�d�|jdt�tjd�dtd�d�|�dt�tj�d	�z0|�t�t�t	���|�t�t�t
���Wn4tk
r�|�ttjt	�|�ttjt
�YnX|�t�t�t���dS)
Nz
cos(-pi/2)r?rr�r*zcos(0)z	cos(pi/2)zcos(pi)ra)
rbrcr�cosr[r\rrirrfrgrerjrUrrr�testCos�s$"zMathTests.testCoscCs�|�ttj�|�dt�d�d�|�dt�d�dt�d�dd�|�t�t�t�|�t�t�t�|�t�	t�t
���dS)Nzcosh(0)rrzcosh(2)-2*cosh(1)**2r?ra)rbrcr�coshr[r^rfrgrirrjrUrrr�testCosh�s&zMathTests.testCoshcCsr|�ttj�|�dt�tj�d�|�dt�tjd�d�|�dt�tjd�d�|�d	t�d
�d
�dS)Nzdegrees(pi)g�f@z
degrees(pi/2)r?g�V@zdegrees(-pi/4)rrg�F�z
degrees(0)r)rbrcr�degreesr[r\rUrrr�testDegrees�s
zMathTests.testDegreescCs�|�ttj�|�dt�d�dtj�|�dt�d�d�|�dt�d�tj�|�t�t�t�|�t�t�d�|�	t�
t�t���|�ttjd�dS)	Nzexp(-1)rarzexp(0)rzexp(1)rC�@B)
rbrcrr<r[r]r^rfrgrirrj�
OverflowErrorrUrrr�testExp�szMathTests.testExpcCsN|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�dS)Nzfabs(-1)rarzfabs(0)rzfabs(1))rbrcr�fabsr[rUrrr�testFabs�szMathTests.testFabscCs�|�t�d�d�|�t�d�d�d}tdd�D]J}||9}|�t�|�|�|�t�t|��|�|�t�|�t|��q2|�ttjd�|�ttjd�|�ttjdd�|�ttjd	�|�ttjtj�dS)
NrrrC��rar��
�d�}Ô%�I��)	r^r�	factorialr!rr%rbrer\)rS�totalr$rrr�
testFactorial�szMathTests.testFactorialcCs*|�ttjt�d��|�ttjd�dS)Ng������@�5)rbrcrr��decimal�DecimalrUrrr�testFactorialNonIntegerssz"MathTests.testFactorialNonIntegerscCs(|�ttjdd�|�ttjd�dS)Nr�r��}Ô%�I�T)rbr�rr�rUrrr�testFactorialHugeInputs
sz!MathTests.testFactorialHugeInputscCs>|�ttj�|�ttt�d���|�dt�d�d�|�dt�d�d�|�dt�d�d�|�d	t�d
�d�|�dt�d
�d�|�dt�d�d�|�dt�d�d�|�dt�d�d�Gdd�d�}Gdd�d�}|�dt�|��d�|�ttj|��|�}dd�|_|�ttj|�|�ttj|d�dS)Nruz
floor(0.5)rz
floor(1.0)rrz
floor(1.5)r�zfloor(-0.5)rvrazfloor(-1.0)r�zfloor(-1.5)r����zfloor(1.23e167)g��Nݯ�bzfloor(-1.23e167)g��Nݯ��c@seZdZdd�ZdS)z&MathTests.testFloor.<locals>.TestFloorcSsdSr�rrUrrr�	__floor__#sz0MathTests.testFloor.<locals>.TestFloor.__floor__N)rKrLrMr�rrrr�	TestFloor"sr�c@seZdZdS)z(MathTests.testFloor.<locals>.TestNoFloorNrJrrrr�TestNoFloor%sr�zfloor(TestFloor())r�cWs|SrOrr�rrrr�+r�z%MathTests.testFloor.<locals>.<lambda>)	rbrcr�floorr^rEr�r[r�)rSr�r�r�rrr�	testFloors$
zMathTests.testFloorcCs�|�ttj�|�dt�dd�d�|�dt�dd�d�|�dt�dd�d	�|�d
t�dd�d�|�d
t�dd�d�|�dt�dd�d�|�t�t�td	���|�t�t�d	t���|�t�t�tt���|�ttjd	d�|�ttjt	d	�|�ttjt
d	�|�ttjt	d�|�t�dt	�d�|�t�dt	�d�|�t�dt
�d�|�t�dt
�d�|�t�dd�d�|�t�dt
�d�dS)Nzfmod(10, 1)r�rrCz
fmod(10, 0.5)ruz
fmod(10, 1.5)r�rzfmod(-10, 1)���rzzfmod(-10, 0.5)zfmod(-10, 1.5)r�r���)rbrcr�fmodr[rirrjrerfrgr^rUrrr�testFmod/s(zMathTests.testFmodcs���ttj��fdd�}|dt�d�d�|dt�d�d�|d	t�d
�d�|dt�d
�d���t�t�dt���t�t�dt���t�t�t	�d��dS)NcsB||\}}\}}t||�tks*||kr>��d|||f�dS�Nz%s returned %r, expected %r�rrhrY)rZ�resultr'�mantr<ZemantZeexprUrr�	testfrexpHs
�z&MathTests.testFrexp.<locals>.testfrexpz	frexp(-1)ra)rvrzfrexp(0)r�rrzfrexp(1)r)rurzfrexp(2)r?)rur?)
rbrcr�frexpr^rfrgrirrj)rSr�rrUr�	testFrexpEszMathTests.testFrexpz2fsum is not exact on machines with double roundingcs\ddlm}|j�|j����fdd�}gdfdgdfdddd	d
ddgd	fd
ddgdfd
ddgdfdddgdfdddgdfdd�tdd�D�t�d�fdd�tdd�D�t�d�fd dd!gd"fd#d$d%d&gdfd'd�td(d)d*�D�d+gt�d,�fg}d-d�td�D��|��fd.d�td/�D��d/g�df�t|�D]|\}\}}zt	�
|�}WnRtk
�r�|�d0|||f�Yn*t
k
�r�|�d1|||f�YnX|�||��qBdd2lm}m}	m}
td/�D]z}d3dd4dd5d6gd7}d}td8�D],}|	d|��d3|}
||
7}|�|
��q|
|�||�}|�||�t	�
|���q�dS)9Nr)�
float_infocs�d\}}|D]Z}t�|�\}}tt�|���|�}}||krR|||K}|}n|||K}||7}qtttt|���d��|�}|dkr�d|d>}|d|t||@o�|d|d@�}||7}t�||�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�r?rrr|)	rr�rE�ldexp�max�len�binr�bool)�iterableZtmantZtexprr�r<�tail�h)�etiny�mant_digrr�msumjs
"(z MathTests.testFsum.<locals>.msumrCr�rr��0��.�++g�d~�QJr�g�d~�Q�g@Crvg��g������?Cg�9g@Cg@Cg@Cg������?Crug�<g������?CcSsg|]}d|�qS�rr��.0rrrr�
<listcomp>�sz&MathTests.testFsum.<locals>.<listcomp>ri�z0x1.df11f45f4e61ap+2cSsg|]}d||�qS)r�rr�rrrr��sz-0x1.62a2af1bd3624p-1r	g��ؗ�Ҝ<g��7y�ACg��7y�ACg�������?g��7y�A�g�������cSs,g|]$}d|d|dd|d�qS)r��2�4rr�rrrr��s����i�r?g�z0x1.5555555555555p+970cSsg|]}d|�qS)g333333�?r�r�r$rrrr��scs g|]}�|d�|�qS)rrr�)�termsrrr��sr�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�i����gh�$.5���g#B����;r���)�sysr�r��min_expr!r�fromhex�append�	enumerater�fsumr�rYrer^r�r�r�)rSr�r��test_valuesr$Zvalsr'�actualr�r�r��j�s�vr)r�r�r�r�testFsumWsj
����� ��
�zMathTests.testFsumcCsztj}|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d	�|�|dd
�d	�|�|dd�d
�d}d}d}||}||}|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�d}||}||}|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�t|dd�|�t|dd�|�|td�td��d	�dS)Nrrrar�i����x�T�i����l j9W P)�}l "o�`T"-� i�	l�8P9�cC�/�[�N
S�9�b�Xl	9@{�wM�2�75�k lZ��'^%#�>�;�*Q!/61^�^@gU@)r�gcdr^rbrcrN)rSr��cr�y�a�brrr�testGcd�sV��zMathTests.testGcdcCs�ddlm}ddlm}tj}tjtjt�d�t�	d�t�
d�f}tt|�d�D]8}|�
||d|��t�tdd	�|d|�D����qR|�|d
d�d�|�|d
d�d�|�||d
�|d��d�|�||d
d�|dd��|dd��|�|td�td�td�td��t�d��|�|dd�d�|�|d�d�|�|�d�|�dt�d|d���|�|ddd�|ddd��|�t��|dd�W5QRX|�t��|ddd�W5QRXdtjjd}|�ttf��|d|�W5QRX|�|t�t�|�|dt�t�|�|dt�t�|�|dt�t�|�|tt�t�|�|tt�t�|�|tt�t�|�|tt�t�|�|tt�t�|�|tt�t�|�|dt�t�|�t�|t���|�t�|dt���|�t�|td���|�t�|dt���|�t�|tt���|�t�|t���td}td�D]&}|�||g|�|t�|���qPtd�D]2}	td|	}
|�t�d |
d|
�d|
��q�dS)!Nr�r���Fractionr��@g������@rcss|]}|dVqdS)r?Nr)r�r�rrr�	<genexpr>�sz&MathTests.testHypot.<locals>.<genexpr>g(@�@�*@r�rB�
r�r|rC�%��%@rrzr�ru)r皙�����?�string皙����@r�r�r�rr) r�r��	fractionsr�r�hypotr]r\�sqrt�gamma�sinr!r��assertAlmostEqual�sumr^r�r�rbrcr�r��
max_10_exprer�rfrjrgrir�	FLOAT_MAX�	FLOAT_MIN)rSr�r�rr�r$�int_too_big_for_float�	fourthmaxrr<�scalerrr�	testHypot�sl$�$,�

�$zMathTests.testHypotcCs<ddlm}ddlm}tj}tj}|�|dd�d�|�|dd�d�td	�D]h}td
�D]Z}t	dd�t|�D��}t	d
d�t|�D��}|�
|||�|tdd�t||�D����q\qP|�|dddgdddg�d�|�|t
dddg�t
dddg��d�|�|dd�d�|�|dd�d�|�||d�|d�f|d�|d�f�|d��|�||dd�|dd�f|dd�|dd�f�|dd��|�|dd �|d��|�|d!d!�d"�|�|d#d#�d"�|�dt�d|d$d%���|�dt�d|d%d$���|�|d&d'�|d(d'��Gd)d*�d*t	�}	|�||	d�d�d�|�t��|dd+d,�W5QRX|�t��|d�W5QRX|�t��|dd+d-�W5QRX|�t��|dd�W5QRX|�t��|d.d�W5QRX|�t��|d/d0�W5QRX|�t��|dd1�W5QRX|�t��|d2d3�W5QRXd4tjjd
}
|�ttf��|d|
fd5�W5QRX|�ttf��|d5d|
f�W5QRXtd6�D]6}t��t��}}|�||f|f�t||���q�td7d8d"d9ttg}tj|d:d;�D]~}tj|d:d;�D]h}d<d=�t||�D�}tttj|���rF|�|||�t�n(tttj |���r|�!t� |||����q�q�t"d}
td�D]P}|
f|}d%|}|�|||�|
t�|��|�|||�|
t�|���q�td�D]V}t#d|}d>|d:|f}d?}|�t�||�d
|�|�t�||�d
|��q�dS)@Nrr�r�)rr�r�)r�r�r�r�)rr?r|)rrr?ra�	rBcss|]}t�dd�VqdS����rBN�r��uniform�r��krrrr�<sz%MathTests.testDist.<locals>.<genexpr>css|]}t�dd�VqdSrrrrrrr�=scss|]\}}||dVqdS)r�Nr�r�ZpxZqxrrrr�@srr�r�r�r�)g,@r)r�r�r�)�r)r?���r�rrr?rr�)TTFTF)TFTTF)g�*@g)@g
�rCr)rz)rC)r�r�ru)rrr)r�rur�c@seZdZdS)zMathTests.testDist.<locals>.TNrJrrrr�Tbsr)rrrB�)�p�q)r��r)r�r�r)rr?r|rr)rBrr�)rrrBrr��abcZxyzr�)r?r|�r�rzr�r|)�repeatcSsg|]\}}||�qSrrrrrrr��sz&MathTests.testDist.<locals>.<listcomp>rr)rCrC)$r�r�rr�r�distrr^r!�tuplerr�zip�iterr�rbrcrer�r�rr�r�rrgrfrj�	itertools�product�any�maprrrir	r
)rS�D�Fr!rr$r�rrrr�valuesZdiffsrrr<r
rrr�testDist-s��&.,��������"
 zMathTests.testDistcCs�ttd��ttdd��dd�tdd�D�dd	d
dg}|D]^}|j|d��Ht�|�}|�t|�t�|�|||�|�	||d
|d
�W5QRXqB|�
t��t�d�W5QRXt�d�}|�t|�t�|�|d
�t�d�}|�t|�t�|�|d�Gdd�dt
�}t�|d��}|�t|�t�|�|d�|�
t��t�|d��W5QRXddt�d�dddg}|D]>}|j|d��&|�
t��t�|�W5QRXW5QRX�q�dS)Nr�iX>i(FcSs(g|] }tdd�D]}d||�qqS)i����(r?)r!)r�r]r$rrrr��sz'MathTests.testIsqrt.<locals>.<listcomp>�<r�r|i'r�i�rPrraTFrc@seZdZdd�Zdd�ZdS)z(MathTests.testIsqrt.<locals>.IntegerLikecSs
||_dSrOrPrRrrrrT�sz1MathTests.testIsqrt.<locals>.IntegerLike.__init__cSs|jSrOrPrUrrrrV�sz2MathTests.testIsqrt.<locals>.IntegerLike.__index__NrWrrrr�IntegerLike�sr/i��)���r�za stringz3.5y@gY@r�)�listr!�subTestr�isqrt�assertIsr�rE�assertLessEqualZ
assertLessrbrer^�objectr�r�rc)rSr�rQr�r/Z
bad_valuesrrr�	testIsqrt�sN
����
$

�zMathTests.testIsqrtc	Cs:|�ttj�|�dt�dd�d�|�dt�dd�d�|�dt�dd�d�|�d	t�dd�d
�|�ttjdd�|�ttjd
d�|�t�dd�d�|�t�d
d�d�|�t�td�t�|�t�td�t�|�	t�
t�td���dddddfD�]0}|�t�t|�t�|�t�t|�t�|�t�d|�d�|�t�d
|�d�|�t�d|�d�|�t�d|�d�|�	t�
t�t|���|�ttjd|�|�ttjd
|�|�t�d|�d�|�t�d|�d�|�t�t|�t�|�t�t|�t�|�	t�
t�t|����qdS)Nz
ldexp(0,1)rrz
ldexp(1,1)r?zldexp(1,-1)raruzldexp(-1,1)r�rr�r�i���rCrz�i+���i��ld(	� F�x:^Vr�r-)rbrcrr�r[r�r^rfrgrirrj�rSrrrr�	testLdexp�s6zMathTests.testLdexpcCs|�ttj�|�dt�dtj�d�|�dt�d�d�|�dt�tj�d�|�dt�dd	�d
�|�dt�dd
d�d
�|�dt�dd
d�d	�|�dt�dd�d�|�ttjd�|�ttjdd�|�ttjt�|�t�t	�t	�|�
t�t�t���dS)Nzlog(1/e)rrazlog(1)rzlog(e)z	log(32,2)r�r?rBzlog(10**40, 10)r�r-zlog(10**40, 10**20)r:z
log(10**1000)r�gO�+��@r�)
rbrcr�logr[r]rergr^rfrirrjrUrrr�testLog�s�zMathTests.testLogcCsh|�ttj�dddddfD] }|�t�|�t�t|���q |�ttjd�|�t�t�t�dS)Nr?�Zi,ra)	rbrcr�log1prrrer^rfr;rrr�	testLog1ps
zMathTests.testLog1pcCs�|�ttj�|�t�d�d�|�t�d�d�|�t�d�d�|�t�dd�d�|�t�dd	�d
�|�t�dd�d�|�ttjd
�|�ttjt�|�t�t�t	���dS)NrrCr?rrrr�i�g��@�g�@i�g@�@r�)
rbrcr�log2r^rergrirrjrUrrr�testLog2
szMathTests.testLog2r�cCs8dd�tdd�D�}dd�tdd�D�}|�||�dS)NcSsg|]}t�t�d|���qSr�)rrCr�r�rrrr�!sz+MathTests.testLog2Exact.<locals>.<listcomp>r�rBcSsg|]}t|��qSr�rr�rrrr�"s)r!r^)rSr�r'rrr�
testLog2ExactszMathTests.testLog2ExactcCs�|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�|�d	t�dd
�d�|�ttjd�|�ttjdd
�|�ttjt�|�t�t	�t	�|�
t�t�t���dS)
Nz
log10(0.1)皙�����?razlog10(1)rrz	log10(10)r�zlog10(10**1000)r�g@�@r�)
rbrcr�log10r[rergr^r=rfrirrjrUrrr�	testLog10%szMathTests.testLog10cs���ttj��fdd�}|dt�d�d�|dt�d�d���t�t�d	tf���t�t�d
tf�t�t�}��t�	|d����t�	|d��dS)
NcsF||\}}\}}t||�tks.t||�rB��d|||f�dSr�r�)rZr�r'Zv1Zv2Ze1Ze2rUrr�testmodf4s
�z$MathTests.testModf.<locals>.testmodfz	modf(1.5)r�)rurz
modf(-1.5)r�)rvr�rCrzrr)
rbrcr�modfr^rfrgrjrir)rSrJZmodf_nanrrUr�testModf1s
zMathTests.testModfcCs�|�ttj�|�dt�dd�d�|�dt�dd�d�|�dt�dd�d�|�dt�dd�d	�|�t�td�t�|�t�td�t�|�t�dt�d
�|�t�dt�d
�|�t�	t�t
d���|�t�	t�dt
���|�t�	t�dt
���|�t�dt
�d�|�t�dt�d�|�t�dd�d�|�t�dd
�d�|�t�dd�d�|�t�dd�d
�|�t�dd�d
�|�ttjdd�|�ttjdd�|�ttjdd�|�ttjdt�|�t�	t�dt
���|�t�tt�t�|�t�td�t�|�t�td
�t�|�t�td�t�|�t�td�d
�|�t�td�d
�|�t�td�d�|�t�td�d�|�t�td�d�|�t�tt�d�|�t�	t�tt
���|�t�dt�d�|�t�dd�d�|�t�dd
�d�|�t�dd�d�|�t�dd�d
�|�t�dd�d
�|�ttjdd�|�ttjdd�|�ttjdd�|�ttjdt�|�t�	t�dt
���|�t�tt�t�|�t�td�t�|�t�td
�t�|�t�td�t�|�t�td�d
�|�t�td�d
�|�t�td�d�|�t�td�d�|�t�td�d�|�t�tt�d�|�t�	t�tt
���|�t�dt�d
�|�t�dd�d�|�ttjdd
�|�t�dd�d
�|�t�dd�d
�|�t�dd�d
�|�t�dd�d
�|�ttjdd�|�t�dd�d�|�t�dt�d
�|�t�	t�dt
���|�t�d
t�d
�|�t�d
d�d
�|�t�d
d
�d
�|�t�d
d�d
�|�t�d
d�d
�|�t�d
d�d
�|�t�d
d�d
�|�t�d
d�d
�|�t�d
d�d
�|�t�d
t�d
�|�t�d
t
�d
�|�t�d
d�d
�|�t�dd�d
�|�t�t
d�d
�|�t�d
d�d
�|�t�dd�d
�|�t�t
d�d
�|�ttjdd
�|�ttjdd�|�t�dt�d�|�t�dt�d�|�t�dt�t�|�t�dt�t�|�t�dt�t�|�t�dt�t�|�t�dt�d�|�t�dt�d�|�t�dt�t�|�t�dt�t�|�t�dt�d�|�t�dt�d�|�t�dt�d�|�t�dt�d�|�t�dt�t�|�t�dt�t�|�dt�dd�d�|�d t�dd�d!�|�d"t�dd
�d�|�d#t�dd�d
�|�d$t�dd�d
�|�d%t�dd�d&�|�d't�dd�d(�|�d)t�dd�d*�|�ttjdd&�|�ttjdd	�dS)+Nzpow(0,1)rrzpow(1,0)zpow(2,1)r?z	pow(2,-1)rarurrCr�r{r�rzg�ryr�r�g.�g�������gffffff�?r���������?rGg��������g�������g�������gffffff��z	(-2.)**3.g �z	(-2.)**2.r�z	(-2.)**1.z	(-2.)**0.z
(-2.)**-0.z
(-2.)**-1.rvz
(-2.)**-2.g�?z
(-2.)**-3.g��)rbrcr�powr[r^rfrgrirrjrerUrrr�testPowDs�zMathTests.testPowcCsr|�ttj�|�dt�d�tj�|�dt�d�tjd�|�dt�d�tjd�|�d	t�d
�d
�dS)Nzradians(180)�zradians(90)r?r?zradians(-45)i���rrz
radians(0)r)rbrcr�radiansr[r\rUrrr�testRadians�s
zMathTests.testRadiansc0s�ddlm���fdd�}ddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4g0}|D]t}�j|d5��^|��\}}}t�|�}t�|�}t�|�}	||||	�t�||�}
��|
�	�|	�	��W5QRXq�t�d6�}t
d7d8�D]h}|dk�r�q||}t
d9�D]B}
|
|}t�||�}
||||
�t�||�}
||||
��q.�qtd:d;d<d=tt
fD]*}��t�t|����t�|t���q�d>D].}��t�|t
�|���t�|t�|��q�td=d;d:d?t
fD]�}��t��t�t
|�W5QRX��t��t�t|�W5QRX��t��t�|d:�W5QRX��t��t�|d;�W5QRX�q�dS)@Nrr�cs��|��|��|�}}}��t|�t|d��|||}��|t|��t|�t|d�kr|��|dt|d��dS)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.
            r?N)r6rr^rE)rr��rZfxZfy�frr�r�rSrr�
validate_spec�sz.MathTests.testRemainder.<locals>.validate_specz-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���r�rCrzr�ry)ryrzrCr{r{)rr�r3r2rr�r�	remainderr^�hexr!rjrgrf�assertIsNaNrbre)rSrVZ	testcasesrWZx_hexZy_hexZexpected_hexrr�r'r�Ztinyr�mrQrrUr�
testRemainder�s��;


 

zMathTests.testRemaindercCs�|�ttj�|�dt�d�d�|�dt�tjd�d�|�dt�tjd�d�z0|�t�t�t���|�t�t�t	���Wn4t
k
r�|�t
tjt�|�t
tjt	�YnX|�t�t�t���dS)Nzsin(0)rz	sin(pi/2)r?rz
sin(-pi/2)ra)rbrcrrr[r\rirrfrgrerjrUrrr�testSinaszMathTests.testSincCs�|�ttj�|�dt�d�d�|�dt�d�dt�d�dd�|�dt�d�t�d�d�|�t�t�t�|�t�t�t�|�	t�
t�t���dS)Nzsinh(0)rzsinh(1)**2-cosh(1)**2rr?razsinh(1)+sinh(-1))rbrcr�sinhr[r�r^rfrgrirrjrUrrr�testSinhns&zMathTests.testSinhcCs�|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�|�t�t�t�|�ttjd�|�ttjt�|�	t�
t�t���dS)	Nzsqrt(0)rzsqrt(1)rzsqrt(4)rrr?ra)rbrcrrr[r^rfrergrirrjrUrrr�testSqrtwszMathTests.testSqrtcCs�|�ttj�|�dt�d�d�|�dt�tjd�d�|�dt�tjd�d�z0|�t�t�t���|�t�t�t	���Wn,|�t
tjt�|�t
tjt	�YnX|�t�t�t���dS)Nztan(0)rz	tan(pi/4)rrrz
tan(-pi/4)ra)rbrcr�tanr[r\rirrfrgrerjrUrrr�testTan�szMathTests.testTancCs�|�ttj�|�dt�d�d�|jdt�d�t�d�dtd�d�|�dt�t�d�|�dt�t�d�|�t�	t�t
���dS)	Nztanh(0)rztanh(1)+tanh(-1)rrar�z	tanh(inf)z
tanh(-inf))rbrcr�tanhr[rrfrgrirrjrUrrr�testTanh�s�zMathTests.testTanhcCs8|�t�d�d�|�t�dt�d��t�dd��dS)Nrzr)r^rrdr�rUrrr�testTanhSign�s
�zMathTests.testTanhSigncCs&|�t�d�d�|�t�d�d�|�tt�d��t�|�tt�d��t�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d	�d
�Gdd�dt�}Gd
d�dt�}|�t�|��d�|�ttj�|�ttjdd�|�ttj|��dS)Nrrar�r�g����?g�����g�!��rg-���?Y�i����c@seZdZdd�ZdS)z'MathTests.test_trunc.<locals>.TestTrunccSsdS)N�rrUrrr�	__trunc__�sz1MathTests.test_trunc.<locals>.TestTrunc.__trunc__N)rKrLrMrhrrrr�	TestTrunc�sric@seZdZdS)z)MathTests.test_trunc.<locals>.TestNoTruncNrJrrrr�TestNoTrunc�srjrgr?)r^r�truncr�rEr7rbrc)rSrirjrrr�
test_trunc�s zMathTests.test_trunccCs�|�t�d��|�t�d��|�t�d��|�t�d��|�t�td���|�t�td���|�t�td���dS)NrCrzrr�rrr)rir�isfinite�assertFalserrUrrr�testIsfinite�szMathTests.testIsfinitecCsx|�t�td���|�t�td���|�t�td�d��|�t�td���|�t�d��|�t�d��dS)Nrz-nanrrCr)rirrrrnrUrrr�	testIsnan�szMathTests.testIsnancCs�|�t�td���|�t�td���|�t�d��|�t�d��|�t�td���|�t�d��|�t�d��dS)Nrrg�g�rrCr)rirrrrnrUrrr�	testIsinf�szMathTests.testIsinfcCs|�t�tj��dSrO)rirrrrUrrr�test_nan_constant�szMathTests.test_nan_constantcCsJ|�t�tj��|�tjd�|�tjtd��|�tjtd��dS)NrCrr)rirrrZ
assertGreaterr^rrUrrr�test_inf_constant�szMathTests.test_inf_constantzrequires verbose modecCs�zt�d�}Wn|�d�YnX|dkr8|�d�zt�d�}Wntk
rZYnX|�d�zt�d�}Wntk
r�YnX|�d�dS)	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)rr<rYr�rre)rSrrrr�test_exceptions�s 

zMathTests.test_exceptionsc	Csldh}d}tjdkrNt��d}zttt|�d���}Wntk
rLYnXd}g}tt	�D]�\}}}}	}
}}|	dks^|dkr�q^|dkr�q^|dk	r�|dkr�||kr�q^t
t|�}
d	|ks�d
|kr�d}
nd|kr�d
}
z|
|�}Wn0tk
r�d}Yntk
�rd
}YnXd\}}t
|
|||�}|dk�r2q^|�||||�}|�|�q^|�rh|�dd�|��dS)NZtan0064�darwinr�.�{}: {}({!r}): {}rC)ZrectZpolar)r�rB�invalid�divide-by-zerore�overflowr��rBrCzFailures in test_testfile:
  �
  )r��platformZmac_verr"r(rEr2rerA�	test_file�getattrrr�rHr&r�rY�join)rSZ
SKIP_ON_TIGERZosx_versionZversion_txtrG�failuresr8r9�arZaiZer�eir=�funcr�r)r*rF�msgrrr�
test_testfilesN



�zMathTests.test_testfilec	Cs,d}g}tt�D]�\}}}}}tt|�}d|ks8d|kr>d}nd|krJd}z||�}	Wn.tk
rnd}	Yntk
r�d}	YnXd\}
}|dkr�d	}
n>|d
kr�d}n0|dkr�|d
kr�|dkr�d}
n|dkr�d}
nd}
t||	|
|�}|dkr�q|�||||�}
|�|
�q|�r(|�	dd�
|��dS)Nrwrxryrerzr�r{rr�lgammagV瞯�<�erfcrCrr��$@r�r�zFailures in test_mtestfile:
  r|)r>�math_testcasesrrrer�rHr&r�rYr�)rSrGr�r8r9r:r'r=r�r(r)r*rFr�rrr�test_mtestfile:sD

�zMathTests.test_mtestfilec
Csvtj}|�|g�d�|�|gdd�d�|�|ttdd���d�|�|tttdd����d�|�|tdd�dd�d�|�|ddd	d
dg�d�|�|dd
dddg�d�|�|ddd	ddg�d�|�|dd
dd
dg�d�|�|dddddg�d�|�|dddddg�td��|�t|�|�t|d�|�t|dddg�|�t|dddgd�|�t|ddgd�t	d�t	d�g}|�t||t	d��|�t|dgdgd	gg�|�t|dd	ig�|�t|dd	igddd	i�|�t|dgdgd	ggg�|�t��|ddgddg�W5QRX|�|dddd	g�d�|�|dddd	g�d�|�|ddd	dg�d�d0d d!�}tdd"�}|�||�||��td#d$�}|�||�||��td%d&�}|�||�d�d'd(�tdd&�D�}|�||�||��d)d(�td%d$�D�}|�||�||��d*d(�td%d&�D�}|�
||��|�
|ddd	td+�dd	g��|�
|ddtd+�dd	g��|�
|dtd+�dd	g��|�
|dtd,�td+�d	g��|�
|dtd-�td+�d	g��|�
|dtd+�td,�d	g��|�
|dtd+�td-�d	g��|�|ddd	td,�d.d
g�td-��|�|ddd	td-�d.d
g�td,��|�
|dddtd,�d.d
g��|�
|dddtd-�d.d
g��|�
|ddd	td,�d.dd	g��|�
|ddd	td-�d.ddg��|�t|ddd	d
dd/g��t�|�t|dd
d	d
dd/g��t�|�t|tdd"���t�|�t|tdd"�dd��t�|�t|dt
�d
�d	d
dd/g��t
j�dS)1NrrB)rr?ri�r�i_7r|rrr�rr�r�r�r�r�lr�r�r�r���a�cr��brr9r-rcSs|D]}||9}q|SrOr)r�r�elemrrr�_naive_prod�s
z(MathTests.test_prod.<locals>._naive_prodi'i���rai���r�cSsg|]}t|��qSrrE�r�rrrrr��sz'MathTests.test_prod.<locals>.<listcomp>cSsg|]}t|��qSrrEr�rrrr��scSsg|]}t|��qSrrEr�rrrr��srrrr1r)r)r�prodr^r2r!r$rrbrc�	bytearrayr[r�rEr�r�)rSr�r+r�r�rrr�	test_prod}sz



$$     �zMathTests.test_prodc	CsLtj}tj}td�D]8}t|d�D]&}|�|||�||�|||��q$qtdd�D]F}td|�D]6}|�|||�||d|d�|||d|��qfqXtdd�D]>}|�||d�d�|�||d�|�|�|||�||��q�td�D].}|�||�||��|�||d�||��q�|�t|dd�|�t|dt�d��|�t|dd�|�t|dd�|�t|t�d�d�|�t|d	d�|�t|�|�t|ddd
�|�t|�|�t	|dd�|�t	|dd
d�|�t	|dd�|�t	|ddd
�|�|dd�d�|�|ddd
�d�dd
}|�||d�d�|�||d�|�|�||d�||d�t
jdd��r�|�t|||�dD]2\}}|�|||�d�|�
t|||��t��q�|�|td�td��d�|�|td�td��d�td
�D]B}|�
t|td�t|���t�|�
t|td�t|���t��qdS)Nr�rrrr�r�1r��10r|rar?r�T�Zcpython�)TT)TF)FFrB)r�permr�r!r^rbrcr�r�rer�check_impl_detailr�r5r�rErIrN)rSr�r�rrrrr�testPerm�s\�6zMathTests.testPermc
Cs�tj}tj}td�D]@}t|d�D].}|�|||�||�||�|||��q$qtdd�D]B}td|�D]2}|�|||�||d|d�||d|��qnq`td�D](}|�||d�d�|�|||�d�q�tdd�D],}|�||d�|�|�|||d�|�q�td�D]6}t|d�D]"}|�|||�||||���q&�q|�t|dd�|�t|dt�d��|�t|dd�|�t|dd�|�t|t�d�d�|�t|d	d�|�t|d�|�t|ddd
�|�t|�|�t	|dd�|�t	|ddd�|�t	|dd�|�t	|ddd�|�|dd�d�|�|ddd�d�dd}|�||d�d�|�||d�|�|�||d�||dd�|�|||�d�|�|||d�|�|�|||d�||dd�t
jd
d��r|�t|||d�dD]2\}}|�|||�d�|�
t|||��t��q|�|td�td��d�|�|td�td��d�td
�D]B}|�
t|td�t|���t�|�
t|td�t|���t��q�dS)Nr�rrr?r�rr�r�r�r|rar�Tr�r�rB)r�combr�r!r^rbrcr�r�rerr�r�r5r�rErIrN)rSr�r�rrrrr�testCombsf�
2$"zMathTests.testCombc
Cs`Gdd�d�}tjtjtjfD]<}|�}|�t��|d|�W5QRX|�t|dd��qdS)Nc@seZdZdd�ZdS)z$MathTests.test_issue39871.<locals>.FcSsd|_dddS)NTrr)�	convertedrUrrr�	__float__]sz.MathTests.test_issue39871.<locals>.F.__float__N)rKrLrMr�rrrrr*\sr*znot a numberr�F)rr}r�rYrbrcrnr)rSr*r�r�rrr�test_issue39871YszMathTests.test_issue39871cCst�|�s|�d�|��dS)NzExpected a NaN, got {!r}.)rrrYr&rRrrrr[ks
zMathTests.assertIsNaNN)rBrC)ErKrLrMr[r`rkrmrorqrtrxr~r�rr�r�r�r�r�r�r�r�rZcpython_onlyr�r�r�r��unittestZskipIf�HAVE_DOUBLE_ROUNDINGr�r�rr,r8r<r>rArDZrequires_mac_verrFrIrLrOrRr]r^r`rarcrerfrlrorprqrrrsZ
skipUnlessrrtr�r�r�r�r�r�r[rrrrrX�s�


		=
!

�^+Jq5 



	

	
		




8
BV@FrXc@s�eZdZejZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) �IsCloseTestscOs*|j|j||f|�|�d||fd�dS)Nz%s and %s should be close!�r�)ri�isclose�rSr�r�r��kwargsrrr�
assertIsClosess
�zIsCloseTests.assertIsClosecOs*|j|j||f|�|�d||fd�dS)Nz%s and %s should not be close!r�)rnr�r�rrr�assertIsNotClosews
�zIsCloseTests.assertIsNotClosecOs&|D]\}}|j||f|�|�qdSrO)r��rSZexamplesr�r�r�r�rrr�assertAllClose{szIsCloseTests.assertAllClosecOs&|D]\}}|j||f|�|�qdSrO)r�r�rrr�assertAllNotCloseszIsCloseTests.assertAllNotClosec	CsR|�t��|jdddd�W5QRX|�t��|jddddd�W5QRXdS)Nrg0��.�+���rel_tolr�g _�©r�r*)rbrer�rUrrr�test_negative_tolerances�sz%IsCloseTests.test_negative_tolerancescCs$ddddddg}|j|ddd�dS)	N)r�r�)�N���@ir�)�;���r�)i90g��@)rCrz)�NFr�rCr��r�)rSZidentical_examplesrrr�test_identical�s�zIsCloseTests.test_identicalcCs*dddg}|j|dd�|j|dd�dS)N)g�חAg�חA)g:�0�yE�g��n�yE�)g�	ѭ��?gfN�ӭ��?�:�0�yE>r���&�.>�r�r�)rSZeight_decimal_places_examplesrrr�test_eight_decimal_places�s�z&IsCloseTests.test_eight_decimal_placescCs*dddg}|j|dd�|j|dd�dS)N)r�rC)g��&�.�rC)gu�?j�/ʠrCrMr�r�r�)r�r�)rSZnear_zero_examplesrrr�test_near_zero�s�zIsCloseTests.test_near_zerocCs<|�tt�|jttdd�|�tt�|jttdd�dS)NrCr�)r�rfrgrUrrr�test_identical_infinite�sz$IsCloseTests.test_identical_infinitecCsRttftdfdtfttfttfttftdfdtftdfdtfg
}|j|dd�dS)Nr�rg������g�������?r�)rjrfrgr�)rSZnot_close_examplesrrr�test_inf_ninf_nan�s�zIsCloseTests.test_inf_ninf_nancCs4dddg}|j|dd�dddg}|j|dd�dS)	N)rr)�333333�r�)�Y��n��r�rCr�)rg�?)g�������?r)gZb���tigTb���tir�)rSZzero_tolerance_close_examplesZ!zero_tolerance_not_close_examplesrrr�test_zero_tolerance�s��z IsCloseTests.test_zero_tolerancecCs|jddgdd�dS)N)rr�)r�rrGr�r�rUrrr�test_asymmetry�szIsCloseTests.test_asymmetrycCs(ddg}|j|dd�|j|dd�dS)N)����)i�[i�[r�r�r�r�)rSZinteger_examplesrrr�
test_integers�s
�zIsCloseTests.test_integerscCshddlm}|d�|d�f|d�|d�f|d�|d�f|d	�|d
�fg}|j|dd�|j|d
d�dS)Nrr�z
1.00000001z1.0z1.00000001e-20z1.0e-20z1.00000001e-100z1.0e-100z
1.00000001e20z1.0e20r�r�r�)r�r�r�r�)rSr�Zdecimal_examplesrrr�
test_decimals�s�zIsCloseTests.test_decimalscCsdddlm}|dd�d|d�f|d�|d�f|dd�|dd�fg}|j|dd	�|j|d
d	�dS)Nrr�rr�r�l �	(q�e�	r:r�r�r�)rr�r�r�)rSr�Zfraction_examplesrrr�test_fractions�s�zIsCloseTests.test_fractionsN)rKrLrMrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�ps 

r�cCsNddlm}t��}|�t�t��|�t�t��|�|d��t|�dS)Nr)�DocFileSuitezieee754.txt)	�doctestr�r�Z	TestSuiteZaddTestZ	makeSuiterXr�r)r�Zsuiterrr�	test_main�sr�)rBrC)8Ztest.supportrrr�testrr�r%r�r�osr}r�r
r�rhrrjrfrgr�r�r	�minr
rr�r�rK�argv�file�__file__�path�dirname�curdirZtest_dirr�r�r~rrrrr%r,r>rArHrErIr7rNZTestCaserXr�r�rrrr�<module>sh-
-~{


F1le Man4ger