Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_math.cpython-39.opt-1.pyc

a

��g�]�@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-d+dd�Z.Gdd �d �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.
    z<qz<drl)�struct�unpack�pack)�x�n�r�*/usr/local/lib/python3.9/test/test_math.py�to_ulps's
rcCs|rdt||d@�SdS)zANumber of '1' bits in binary expansion of a nonnnegative integer.�r)�count_set_bits)rrrrrMsrcCsD||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
numfactorsZmidrrrrQs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_factorial_s
*
rcCsLtt|�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)�absr�format)�expected�got�ulp_tol�abs_tolZ	ulp_errorZ	abs_error�fmtrrr�
ulp_abs_checkjsr%ccs�t|���}|D]x}d|vr,|d|�d��}|��s6q|�d�\}}|��\}}}|��}|d}	|dd�}
||t|�t|	�|
fVqWd�n1s�0YdS)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�split�float)�fname�fp�line�lhs�rhs�id�fn�arg�
rhs_pieces�exp�flagsrrr�parse_mtestfile|s	
r8c
	cs�t|���}|D]�}|�d�s|��s&q|�d�\}}|��\}}}}|��}	|	d|	d}
}|	dd�}||t|�t|�t|
�t|�|fVqWd�n1s�0YdS)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(�
startswithr*r+r,)
r-r.r/r0r1r2r3Zarg_realZarg_imagr5Zexp_realZexp_imagr7rrr�parse_testfile�s
�r;��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||||�}|dur�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,�int�math�isnan�isinfr%r)r r!r"r#�failure�fail_fmtZfail_msgrrr�result_check�s&
rEc@seZdZdd�Zdd�ZdS)�	FloatLikecCs
||_dS�N��value��selfrIrrr�__init__�szFloatLike.__init__cCs|jSrGrH�rKrrr�	__float__�szFloatLike.__float__N)�__name__�
__module__�__qualname__rLrNrrrrrF�srFc@seZdZdS)�IntSubclassN�rOrPrQrrrrrR�srRc@seZdZdd�Zdd�ZdS)�MyIndexablecCs
||_dSrGrHrJrrrrL�szMyIndexable.__init__cCs|jSrGrHrMrrr�	__index__�szMyIndexable.__index__N�rOrPrQrLrUrrrrrT�srTc@sneZdZd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�Ze�ejdko�e��dvd�dd��Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zejd*d+��Zd,d-�Zd.d/�Zd0d1�Z e
e�e!d2�d3d4���Z"d5d6�Z#d7d8�Z$d9d:�Z%d;d<�Z&d=d>�Z'd?d@�Z(dAdB�Z)dCdD�Z*e
dEdF��Z+e
e�,dGd�dHdI���Z-dJdK�Z.dLdM�Z/dNdO�Z0dPdQ�Z1e
dRdS��Z2dTdU�Z3dVdW�Z4dXdY�Z5dZd[�Z6d\d]�Z7e
d^d_��Z8d`da�Z9dbdc�Z:ddde�Z;dfdg�Z<e
dhdi��Z=e
djdk��Z>e�?e@dl�dmdn��ZAe
dodp��ZBe
dqdr��ZCdsdt�ZDdudv�ZEdwdx�ZFe
dydz��ZGe
d{d|��ZHd}d~�ZIdd��ZJd�d��ZKd�S)��	MathTestsr<r=cCs,t||||�}|dur(|�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{}: {})rE�failr)rK�namer!r r"r#rCrrr�ftest�s	zMathTests.ftestcCs8|�dtjd�|�dtjd�|�tjdtj�dS)N�pig-DT�!	@�egiW�
�@r9)rZr@r[r\�assertEqual�taurMrrr�
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)rr9zacos(1)r)
�assertRaises�	TypeErrorr@�acosrZr[�
ValueError�INF�NINF�eps�
assertTruerA�NANrMrrr�testAcosszMathTests.testAcoscCs�|�ttj�|�dt�d�d�|�dt�d�d�|�ttjd�|�ttjd�|�t�t�t�|�ttjt�|�	t�
t�t���dS)Nzacosh(1)rrzacosh(2)r9g5�qB�?r`)rarbr@�acoshrZrdr]rerfrhrArirMrrr�	testAcosh
szMathTests.testAcoshcCs�|�ttj�|�dt�d�tjd�|�dt�d�d�|�dt�d�tjd�|�ttjt�|�ttjt�|�ttjdt	�|�ttjdt	�|�
t�t�t���dS)Nzasin(-1)r`r9zasin(0)rzasin(1)r)
rarbr@�asinrZr[rdrerfrgrhrArirMrrr�testAsinszMathTests.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)r`g'�ya64�)rarbr@�asinhrZr]rerfrhrArirMrrr�	testAsinh"szMathTests.testAsinhcCs�|�ttj�|�dt�d�tjd�|�dt�d�d�|�dt�d�tjd�|�dt�t�tjd	�|�d
t�t�tjd	�|�t�	t�t
���dS)Nzatan(-1)r`�zatan(0)rzatan(1)rz	atan(inf)r9z
atan(-inf))rarbr@�atanrZr[rerfrhrArirMrrr�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��rr`)rarbr@rrrZ�atanhrdrerfrhrArirMrrr�	testAtanh4szMathTests.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)r`rr9zatan2(-1, 1)rrqzatan2(0, 1)zatan2(1, 1)zatan2(1, 0)zatan2(0., -inf)r=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.))rarbr@�atan2rZr[rfr]rerhrArirMrrr�	testAtan2?sf "zMathTests.testAtan2cCsf|�ttj�|�ttt�d���|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d	�|�t�d
�d	�|�t�d�d�|�t�d�d�Gd
d�d�}Gdd�dt�}Gdd�d�}|�t�|��d�|�t�|��d�|�t�td��d�|�ttj|��|�}dd�|_	|�ttj|�|�ttj|d�dS)Nrtr��?��?r9rur��r`���r=ryc@seZdZdd�ZdS)z$MathTests.testCeil.<locals>.TestCeilcSsdS�N�*rrMrrr�__ceil__�sz-MathTests.testCeil.<locals>.TestCeil.__ceil__N�rOrPrQr�rrrr�TestCeil�sr�c@seZdZdd�ZdS)z%MathTests.testCeil.<locals>.FloatCeilcSsdSr�rrMrrrr��sz.MathTests.testCeil.<locals>.FloatCeil.__ceil__Nr�rrrr�	FloatCeil�sr�c@seZdZdS)z&MathTests.testCeil.<locals>.TestNoCeilNrSrrrr�
TestNoCeil�sr�r�g@E@�+cWs|SrGr��argsrrr�<lambda>��z$MathTests.testCeil.<locals>.<lambda>)
rarbr@�ceilr]r?�typer,rFr�)rKr�r�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�r~r=i���r�r{�@�@ry���@)r]r@�copysignrarbrerfrhrArirBrrMrrr�testCopysign�s0zMathTests.testCopysigncCs|�ttj�|jdt�tjd�dt�d�d�|�dt�d�d�|jdt�tjd�dt�d�d�|�dt�tj�d	�z0|�t�t�t	���|�t�t�t
���Wn2ty�|�ttjt	�|�ttjt
�Yn0|�t�t�t���dS)
Nz
cos(-pi/2)r9rr�r#zcos(0)z	cos(pi/2)zcos(pi)r`)
rarbr@�cosrZr[�ulprhrArerfrdrirMrrr�testCos�s&$zMathTests.testCos�win32)ZARMZARM64zEWindows UCRT is off by 2 ULP this test requires accuracy within 1 ULPcCs�|�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)**2r9r`)rarbr@�coshrZr]rerfrhrArirMrrr�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)r9g�V@zdegrees(-pi/4)rqg�F�z
degrees(0)r)rarbr@�degreesrZr[rMrrr�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)r`rzexp(0)rzexp(1)r=�@B)
rarbr@r6rZr\r]rerfrhrAri�
OverflowErrorrMrrr�testExp�szMathTests.testExpcCsN|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�dS)Nzfabs(-1)r`rzfabs(0)rzfabs(1))rarbr@�fabsrZrMrrr�testFabs�szMathTests.testFabscCs�|�t�d�d�d}tdd�D]4}||9}|�t�|�|�|�t�|�t|��q |�ttjd�|�ttjdd�dS)Nrr��r`�
�d)r]r@�	factorialrrrard)rK�totalrrrr�
testFactorial�szMathTests.testFactorialcCs*|�t��"|�t�d�d�Wd�n1s20Y|�t�� |�ttjd�Wd�n1sl0Y|�t�� |�ttjd�Wd�n1s�0Y|�t�� |�ttjd�Wd�n1s�0Y|�ttjt�	d��|�ttjt�	d��|�ttjd�dS)N�@�xg������@r��}Ô%�I���5z5.2)
�assertWarns�DeprecationWarningr]r@r�rardrb�decimal�DecimalrMrrr�testFactorialNonIntegers�s0...z"MathTests.testFactorialNonIntegerscCsR|�ttjdd�|�t�� |�ttjd�Wd�n1sD0YdS)Nr�r��}Ô%�I�T)rar�r@r�r�r�rMrrr�testFactorialHugeInputssz!MathTests.testFactorialHugeInputscCsB|�ttj�|�ttt�d���|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d	�d
�Gdd�d�}Gd
d�dt�}Gdd�d�}|�t�|��d�|�t�|��d�|�t�td��d�|�ttj|��|�}dd�|_	|�ttj|�|�ttj|d�dS)Nrtrr~rrrur`r�r����c@seZdZdd�ZdS)z&MathTests.testFloor.<locals>.TestFloorcSsdSr�rrMrrr�	__floor__sz0MathTests.testFloor.<locals>.TestFloor.__floor__N�rOrPrQr�rrrr�	TestFloorsr�c@seZdZdd�ZdS)z'MathTests.testFloor.<locals>.FloatFloorcSsdSr�rrMrrrr�sz1MathTests.testFloor.<locals>.FloatFloor.__floor__Nr�rrrr�
FloatFloorsr�c@seZdZdS)z(MathTests.testFloor.<locals>.TestNoFloorNrSrrrr�TestNoFloor!sr�r�g33333�D@�)cWs|SrGrr�rrrr�)r�z%MathTests.testFloor.<locals>.<lambda>)
rarbr@�floorr]r?r�r,rFr�)rKr�r�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�rr=z
fmod(10, 0.5)rtz
fmod(10, 1.5)rr~zfmod(-10, 1)���ryzfmod(-10, 0.5)zfmod(-10, 1.5)r�r���)rarbr@�fmodrZrhrArirdrerfr]rMrrr�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�rrgrX)rY�resultr �mantr6ZemantZeexprMrr�	testfrexpFs
�z&MathTests.testFrexp.<locals>.testfrexpz	frexp(-1)r`)rurzfrexp(0)r�rrzfrexp(1)r)rtrzfrexp(2)r9)rtr9)
rarbr@�frexpr]rerfrhrAri)rKr�rrMr�	testFrexpCszMathTests.testFrexpz2fsum is not exact on machines with double roundingcs8ddlm}|j�|j����fdd�}gdfdgdfgd�dfgd�d	fgd
�dfgd�d
fgd�dfdd�tdd�D�t�d�fdd�tdd�D�t�d�fgd�dfgd�dfdd�tddd�D�dgt�d�fg}d d�td�D��|��fd!d�td"�D��d"g�df�t|�D]x\}\}}zt	�
|�}WnNt�yl|�d#|||f�Yn(t
�y�|�d$|||f�Yn0|�||��q*dd%lm}m}	m}
td"�D]r}gd&�d'}d}td(�D],}|	d|��d)|}
||
7}|�|
��q�|
|�||�}|�||�t	�
|���q�dS)*Nr)�
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�r9rrr{)	r@r�r?�ldexp�max�len�binr�bool)�iterableZtmantZtexprr�r6�tail�h)�etiny�mant_digrr�msumhs
"(z MathTests.testFsum.<locals>.msumr=)r�r~r��0��.�++g�d~�QJr�g�d~�Q�r�)�@Crug��g������?C)r�r~��9g@C)g@Cr~r�g@C)g������?Crtg�<g������?CcSsg|]}d|�qS�r~r��.0rrrr�
<listcomp>�r�z&MathTests.testFsum.<locals>.<listcomp>ri�z0x1.df11f45f4e61ap+2cSsg|]}d||�qS)r�rr�rrrr��r�z-0x1.62a2af1bd3624p-1)r	r~g��ؗ�Ҝ<g��7y�AC)g��7y�ACg�������?g��7y�A�g�������cSs,g|]$}d|d|dd|d�qS)r��2�4rr�rrrr��r�����i�r9g�z0x1.5555555555555p+970cSsg|]}d|�qS)g333333�?r�r�rrrrr��r�cs g|]}�|d�|�qS)rrr�)�termsrrr��r�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)�r�i����r�gh�$.5���g#B����;r���r�)�sysr�r��min_exprr,�fromhex�append�	enumerater@�fsumr�rXrdr]r�r�r�)rKr�r��test_valuesrZvalsr �actualr�r�r��j�s�vr)r�r�r�r�testFsumUsj





��

��� ��
�zMathTests.testFsumcCsBtj}|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d	�|�|dd
�d	�|�|dd�d
�d}d}dD]�}||}||}|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�q�|�|�d�|�|d�d�|�|d
�d�|�|ddd�d�|�|ddd�d�|�t|d�|�t|dd�|�t|dd�|�t|ddd�|�|td�td��d	�dS)Nrrr`r�����r��T����� j9W P)�}� "o�`T"-� l�8P9�cC�/�[�N
S�9�b�Xl	9@{�wM�2�75�k )��	lZ��'^%#�>�;�*Q!/61^�f��^@�U@)r@�gcdr]rarbrT)rKrr�y�c�a�brrr�testGcd�sN��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�Wd�n1�s�0Y|�t��|ddd�Wd�n1�s�0Ydtjjd}|�ttf��|d|�Wd�n1�s,0Y|�|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�|���q�td�D]2}	td|	}
|�t�d |
d|
�d|
��q�dS)!Nr�r���Fractionr��@g������@rcss|]}|dVqdS)r9Nr)r�r�rrr�	<genexpr>�r�z&MathTests.testHypot.<locals>.<genexpr>g(@r��*@r�r<�
r�r{r=�%��%@r~ryrrt�r皙�����?�string皙����@r�r�r�rq) r�r��	fractionsr
r@�hypotr\r[�sqrt�gamma�sinrr��assertAlmostEqual�sumr]r�r�rarbr�r��
max_10_exprdr�rerirfrhrA�	FLOAT_MAX�	FLOAT_MIN)rKr�r
rr�r�int_too_big_for_float�	fourthmaxrr6�scalerrr�	testHypot�sl$�$,�

�*,*$zMathTests.testHypotcCsddlm}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|�|gd�gd��d�|�|t
gd��t
gd���d�|�|dd�d�|�|dd�d�|�||d�|d�f|d�|d�f�|d��|�||dd�|dd�f|dd�|dd�f�|dd��|�|dd�|d��|�|dd�d�|�|dd�d�|�d t�d |d!d"���|�d t�d |d"d!���|�|d#d$�|d%d$��Gd&d'�d't	�}	|�||	d�d�d�|�t��|dd(d)�Wd�n1�sZ0Y|�t��|d�Wd�n1�s�0Y|�t��|dd(d*�Wd�n1�s�0Y|�t��|dd�Wd�n1�s�0Y|�t��|d+d�Wd�n1�s20Y|�t��|d,d-�Wd�n1�sh0Y|�t��|dd.�Wd�n1�s�0Y|�t��|d/d0�Wd�n1�s�0Yd1tjjd
}
|�ttf��|d|
fd2�Wd�n1�s"0Y|�ttf��|d2d|
f�Wd�n1�s`0Ytd3�D]6}t��t��}}|�||f|f�t||���qrtd4d5dd6ttg}tj|d7d8�D]~}tj|d7d8�D]h}d9d:�t||�D�}tttj|���r|�|||�t�n(tttj |���r�|�!t� |||����qܐq�t"d;}
td�D]P}|
f|}d"|}|�|||�|
t�|��|�|||�|
t�|���qZtd�D]V}t#d|}d<|d7|f}d=}|�t�||�d
|�|�t�||�d
|��q�dS)>Nrrr	)r~r�r�)r�r�r�r�)rr9r{)rqr9r`�	r<css|]}t�dd�VqdS����r<N�r��uniform�r��krrrr9r�z%MathTests.testDist.<locals>.<genexpr>css|]}t�dd�VqdSr$r&r(rrrr:r�css|]\}}||dVqdS)r�Nr�r�ZpxZqxrrrr=r�)g,@r~)r�r�r
)�r)r9���rr+rr9r,r�)TTFTF)TFTTFr�)g�*@g)@g
�r=rr~)ry)r=)rrrt)rrr)rrtrc@seZdZdS)zMathTests.testDist.<locals>.TNrSrrrr�T_sr-)rqr<r�)�p�q)r��r#)rrr)rr9r{rq)r<r�r�)rqr<r�r��abcZxyzr�)r9r{�rryrr{)�repeatcSsg|]\}}||�qSrrr*rrrr��r�z&MathTests.testDist.<locals>.<listcomp>r�rq)r=r=)$r�r�rr
r@�distrr]r�tuplerr�zip�iterr�rarbrdr�r�rr�r�rrfreri�	itertools�product�any�maprBrArhrr)rK�D�Fr4rrr�r.r/r-r�valuesZdiffsr rr6r!rrr�testDist*s��".,��������,(,*****.."
 zMathTests.testDistc
Cs4ttd��ttdd��dd�tdd�D�dd	d
dg}|D]r}|j|d��Rt�|�}|�t|�t�|�|||�|�	||d
|d
�Wd�qB1s�0YqB|�
t��t�d�Wd�n1s�0Yt�d�}|�t|�t�|�|d
�t�d�}|�t|�t�|�|d�Gdd�dt
�}t�|d��}|�t|�t�|�|d�|�
t��t�|d��Wd�n1�s�0Yddt�d�dddg}|D]j}|j|d��F|�
t��t�|�Wd�n1�s0YWd�n1�s"0Y�q�dS)Nr�iX>i(FcSs(g|] }tdd�D]}d||�qqS)i����(r9)r)r�r\rrrrr��r�z'MathTests.testIsqrt.<locals>.<listcomp>�<r�r{i'r�i�rHrr`TFrc@seZdZdd�Zdd�ZdS)z(MathTests.testIsqrt.<locals>.IntegerLikecSs
||_dSrGrHrJrrrrL�sz1MathTests.testIsqrt.<locals>.IntegerLike.__init__cSs|jSrGrHrMrrrrU�sz2MathTests.testIsqrt.<locals>.IntegerLike.__index__NrVrrrr�IntegerLike�srBi�r����rza stringz3.5y@gY@r�)�listr�subTestr@�isqrt�assertIsr�r?�assertLessEqualZ
assertLessrardr]�objectr�r�rb)rKr�rIr�rBZ
bad_valuesrrr�	testIsqrt�sF
����
8(

.�zMathTests.testIsqrtcCsNtj}|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd�d�|�|dd	�d
�|�|d	d�d
�|�|dd
�d�d}d}dD]�}||}||}|||}|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�q�|�|�d�|�|d�d�|�|d�d�|�|dd	d�d�|�|ddd	�d�|�t|d�|�t|dd	�|�t|dd�|�t|ddd�|�|td�td	��d
�dS)Nrrr`r�r�r�iYr�r�iHr�r�r�l ,�`aUx�-�xB�:Vn
Ldbl�m�e%Y%l};T^�	)r�l�|/Kr2r�i�7rr)r@�lcmr]rarbrT)rKrKrrrrr�drrr�test_lcm�sP��zMathTests.test_lcmc	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)r9zldexp(1,-1)r`rtzldexp(-1,1)r�r~r�r�i���r=ry�i+���i��ld(	� F�x:^Vr�r@)rarbr@r�rZr�r]rerfrhrAri�rKrrrr�	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)rr`zlog(1)rzlog(e)z	log(32,2)r�r9r<zlog(10**40, 10)r�r@zlog(10**40, 10**20)rOz
log(10**1000)r�gO�+��@r�)
rarbr@�logrZr\rdrfr]rerhrArirMrrr�testLogs�zMathTests.testLogcCsh|�ttj�dddddfD] }|�t�|�t�t|���q |�ttjd�|�t�t�t�dS)Nr9�Zi,r`)	rarbr@�log1prr,rdr]rerPrrr�	testLog1p,s
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)Nrr=r9r~rqr�i�g��@�g�@i�g@�@r�)
rarbr@�log2r]rdrfrhrArirMrrr�testLog23szMathTests.testLog2r�cCs8dd�tdd�D�}dd�tdd�D�}|�||�dS)NcSsg|]}t�t�d|���qSr�)r@rXr�r�rrrr�Jr�z+MathTests.testLog2Exact.<locals>.<listcomp>r�rWcSsg|]}t|��qSr�r,r�rrrr�Kr�)rr])rKr�r rrr�
testLog2ExactEszMathTests.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)皙�����?r`zlog10(1)rrz	log10(10)r�zlog10(10**1000)r�g@�@r�)
rarbr@�log10rZrdrfr]rRrerhrArirMrrr�	testLog10NszMathTests.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�)rYr�r Zv1Zv2�e1�e2rMrr�testmodf]s
�z$MathTests.testModf.<locals>.testmodfz	modf(1.5)r)rtr~z
modf(-1.5)r�)rur�r=ryrr)
rarbr@�modfr]rerfrirhrA)rKraZmodf_nanrrMr�testModfZs
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)r9z	pow(2,-1)r`rtr~r=r�rzr�ryg�rxr�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.ruz
(-2.)**-2.g�?z
(-2.)**-3.g��)rarbr@�powrZr]rerfrhrArirdrMrrr�testPowms�zMathTests.testPowcCsr|�ttj�|�dt�d�tj�|�dt�d�tjd�|�dt�d�tjd�|�d	t�d
�d
�dS)Nzradians(180)�zradians(90)rTr9zradians(-45)i���rqz
radians(0)r)rarbr@�radiansrZr[rMrrr�testRadianss
zMathTests.testRadiansc	s�ddlm���fdd�}gd�}|D]�}�j|d��h|��\}}}t�|�}t�|�}t�|�}	||||	�t�||�}
��|
�	�|	�	��Wd�q&1s�0Yq&t�d�}t
dd	�D]`}|dkr�q�||}t
d
�D]@}
|
|}t�||�}
||||
�t�||�}
||||
�q�q�tddd
dtt
fD]*}��t�t|����t�|t���q8dD].}��t�|t
�|���t�|t�|��qhtddddt
fD]�}��t��t�t
|�Wd�n1�s�0Y��t��t�t|�Wd�n1�s0Y��t��t�|d�Wd�n1�sJ0Y��t��t�|d�Wd�n1�s�0Y�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.
            r9N)rHrr]r?)rr�rZfxZfy�frr�r
rKrr�
validate_spec
sz.MathTests.testRemainder.<locals>.validate_spec)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���r�r=ryr�rx)rxryr=rzrz)rr
rEr+r,r�r@�	remainderr]�hexrrirfre�assertIsNaNrard)rKrmZ	testcasesrnZx_hexZy_hexZexpected_hexrrr r�Ztinyr�mrIrrlr�
testRemainder	sL;


4
,,,zMathTests.testRemaindercCs�|�ttj�|�dt�d�d�|�dt�tjd�d�|�dt�tjd�d�z0|�t�t�t���|�t�t�t	���Wn2t
y�|�t
tjt�|�t
tjt	�Yn0|�t�t�t���dS)Nzsin(0)rz	sin(pi/2)r9rz
sin(-pi/2)r`)rarbr@rrZr[rhrArerfrdrirMrrr�testSin�szMathTests.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)**2rr9r`zsinh(1)+sinh(-1))rarbr@�sinhrZr�r]rerfrhrArirMrrr�testSinh�s&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)rqr9r`)rarbr@rrZr]rerdrfrhrArirMrrr�testSqrt�szMathTests.testSqrtcCs�|�ttj�|�dt�d�d�|�dt�tjd�d�|�dt�tjd�d�z0|�t�t�t���|�t�t�t	���Wn,|�t
tjt�|�t
tjt	�Yn0|�t�t�t���dS)Nztan(0)rz	tan(pi/4)rqrz
tan(-pi/4)r`)rarbr@�tanrZr[rhrArerfrdrirMrrr�testTan�szMathTests.testTancCs�|�ttj�|�dt�d�d�|jdt�d�t�d�dt�d�d�|�dt�t�d�|�dt�t�d�|�t�	t�t
���dS)	Nztanh(0)rztanh(1)+tanh(-1)rr`r�z	tanh(inf)z
tanh(-inf))rarbr@�tanhrZr�rerfrhrArirMrrr�testTanh�s�zMathTests.testTanhcCs8|�t�d�d�|�t�dt�d��t�dd��dS)Nryr~)r]r@r{r�rMrrr�testTanhSign�s
�zMathTests.testTanhSigncCsZ|�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�}Gd
d�dt�}Gdd�d�}|�t�|��d�|�t�|��d�|�ttj�|�ttjdd�|�ttjtd��|�ttj|��dS)Nrr`rr�g����?g�����g�!��rg-���?Y�i����c@seZdZdd�ZdS)z'MathTests.test_trunc.<locals>.TestTrunccSsdS�N�rrMrrr�	__trunc__�sz1MathTests.test_trunc.<locals>.TestTrunc.__trunc__N�rOrPrQr�rrrr�	TestTrunc�sr�c@seZdZdd�ZdS)z(MathTests.test_trunc.<locals>.FloatTrunccSsdSr~rrMrrrr��sz2MathTests.test_trunc.<locals>.FloatTrunc.__trunc__Nr�rrrr�
FloatTrunc�sr�c@seZdZdS)z)MathTests.test_trunc.<locals>.TestNoTruncNrSrrrr�TestNoTrunc�sr�rr9g�7@)	r]r@�truncr�r?r,rarbrF)rKr�r�r�rrr�
test_trunc�s&zMathTests.test_trunccCs�|�t�d��|�t�d��|�t�d��|�t�d��|�t�td���|�t�td���|�t�td���dS)Nr=ryr~r�rrr)rhr@�isfinite�assertFalser,rMrrr�testIsfinite�szMathTests.testIsfinitecCsx|�t�td���|�t�td���|�t�td�d��|�t�td���|�t�d��|�t�d��dS)Nrz-nanrr=r~)rhr@rAr,r�rMrrr�	testIsnan�szMathTests.testIsnancCs�|�t�td���|�t�td���|�t�d��|�t�d��|�t�td���|�t�d��|�t�d��dS)Nrrg�g�rr=r~)rhr@rBr,r�rMrrr�	testIsinf�szMathTests.testIsinfcCs|�t�tj��dSrG)rhr@rArrMrrr�test_nan_constant�szMathTests.test_nan_constantcCsJ|�t�tj��|�tjd�|�tjtd��|�tjtd��dS)Nr=rr)rhr@rBrZ
assertGreaterr]r,rMrrr�test_inf_constantszMathTests.test_inf_constantzrequires verbose modecCs�zt�d�}Wn|�d�Yn0|dkr8|�d�zt�d�}WntyXYn0|�d�zt�d�}Wnty�Yn0|�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)r@r6rXr�rrd�rKrrrr�test_exceptionss 

zMathTests.test_exceptionsc	Csfdh}d}tjdkrLt��d}zttt|�d���}WntyJYn0d}g}tt	�D]�\}}}}	}
}}|	dks\|dkr�q\|dvr�q\|dur�|dkr�||vr�q\t
t|�}
d	|vs�d
|vr�d}
nd|vr�d
}
z|
|�}Wn,ty�d}Ynt�yd
}Yn0d\}}t
|
|||�}|du�r,q\|�||||�}|�|�q\|�rb|�dd�|��dS)NZtan0064�darwinr�.�{}: {}({!r}): {}r=)ZrectZpolar)r�r<�invalid�divide-by-zerord�overflowr��r<r=zFailures in test_testfile:
  �
  )r��platformZmac_verr5r;r?r+rdr;�	test_file�getattrr@r�rErr�rX�join)rKZ
SKIP_ON_TIGERZosx_versionZversion_txtrD�failuresr2r3�arZaiZer�eir7�funcr�r"r#rC�msgrrr�
test_testfile.sN



�zMathTests.test_testfilec	Cs(d}g}tt�D]�\}}}}}tt|�}d|vs8d|vr>d}nd|vrJd}z||�}	Wn*tyld}	Ynty�d}	Yn0d\}
}|dkr�d	}
n>|d
kr�d}n0|dkr�|d
kr�|dkr�d}
n|dkr�d}
nd}
t||	|
|�}|dur�q|�||||�}
|�|
�q|�r$|�	dd�
|��dS)Nr�r�r�rdr�r�r�rr2�lgammagV瞯�<�erfcr=r~r��$@r�r�zFailures in test_mtestfile:
  r�)r8�math_testcasesr�r@rdr�rErr�rXr�)rKrDr�r2r3r4r r7r�r!r"r#rCr�rrr�test_mtestfilegsD

�zMathTests.test_mtestfilec
Cs�tj}|�|g�d�|�|gdd�d�|�|ttdd���d�|�|tttdd����d�|�|tdd�dd�d�|�|gd	��d
�|�|gd��d�|�|gd
��d�|�|gd��d�|�|gd��d�|�|gd��td��|�t|�|�t|d�|�t|gd��|jt|gd�dd�|jt|ddgdd�t	d�t	d�g}|jt||t	d�d�|�t|dgdgdgg�|�t|ddig�|jt|ddigdddid�|jt|dgdgdgggd�|�|ddgdd�d�|�|ddgddgd�gd��|�|gddid�ddi�|�t��|ddgd�Wd�n1�sf0Y|�|gd��d�|�|gd ��d�|�|gd!��d�d7d"d#�}tdd$�}|�||�||��td%d&�}|�||�||��td'd(�}|�||�d�d)d*�tdd(�D�}|�||�||��d+d*�td'd&�D�}|�||�||��d,d*�td'd(�D�}|�
||��|�
|dddtd-�ddg��|�
|ddtd-�ddg��|�
|dtd-�ddg��|�
|dtd.�td-�dg��|�
|dtd/�td-�dg��|�
|dtd-�td.�dg��|�
|dtd-�td/�dg��|�|dddtd.�d0d1g�td/��|�|dddtd/�d0d1g�td.��|�
|dddtd.�d0d1g��|�
|dddtd/�d0d1g��|�
|dddtd.�d0ddg��|�
|dddtd/�d0ddg��|�t|gd2���t�|�t|gd3���t�|�t|tdd$���t�|�t|tdd$�d4d��t�|�t|dt
�d5�dd1dd6g��t
j�dS)8Nrr<)rr9r0i�r�i_7)rr9r{rqr<r�)r~r�r�r�r�r)rr9r{r�r�)r~r�r�rqr<)rr�rrr�)r~r~r�rrr�)rrr��a�cr��br{�abZabababababab)rr9rr9rr9rr9rr9rr9r2)rrr9r{r)rrr9r{)rr9r{rcSs|D]}||9}q|SrGr)r�r�elemrrr�_naive_prod�s
z(MathTests.test_prod.<locals>._naive_prodi'i���r`i���r�cSsg|]}t|��qSrrZ�r�rrrrr��r�z'MathTests.test_prod.<locals>.<listcomp>cSsg|]}t|��qSrrZr�rrrr��r�cSsg|]}t|��qSrrZr�rrrr��r�rrrrCrq)rr9r{rqr<r�)rr�r{rqr<r�r~r�r�)r)r@�prodr]rDrr7r,rarb�	bytearrayrrr�r?r�r�)rKr�r>r�r�rrr�	test_prod�s�  .



$$   �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�rrr2r�r~�1r��10r{r`r9r�T�Zcpython�)TT)TF)FFr<)r@�permr�rr]rarbr�r�rdr�check_impl_detailr�rGr�r?rRrT)rKr�r�rr)rrr�testPerms\�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�rrr9r�r~r�r�r�r{r`r�Tr�r�r<)r@�combr�rr]rarbr�r�rdrr�r�rGr�r?rRrT)rKr�r�rr)rrr�testCombFsf�
2$"zMathTests.testCombcCs|�t�dt�d�|�t�dt�d�|�t�dd�d�|�t�dd�d�|�t�d	t�t�d
��|�t�d	t�t�d��|�t�dd�d�|�t�d
d�d�|�t�dd
�d
�tjj	tjj
}|�t�dt�|�|�t�d
t�|�|�t�dt�|�|�t�d
t�|�|�t�|d�d�|�t�|d�d
�|�t�|d
�d�|�t�|d
�d
�tjj}|�t�td�|�|�t�td�|�|�t�|t�t�|�t�|t�t�|�t�t
d	��|�t�d	t
��|�t�t
t
��dS)Ng0Cg������/Cg0Cg�Cr=g�������Cg��g��������r~z0x1.fffffffffffffp-1z0x1.0000000000001p+0r�ry)r]r@�	nextafterrer,r��assertEqualSignr�r��min�epsilonr�rrri)rKZsmallest_subnormalZlargest_normalrrr�test_nextafter�sL������zMathTests.test_nextafterc	Cs|�t�d�tjj�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�tjjtjj�|�t�t�tt�tt	��|�t�t	�t	�|�
t�tj��ddddt	fD]J}|j|d��*|�t�|�t�|��Wd�q�1s�0Yq�dS)	Nr~l�lr�lg�@r=r)
r]r@r�r�r�r�r�rr�rerrrrEr�rrr�test_ulp�s��zMathTests.test_ulpc	CstGdd�d�}tjtjtjfD]P}|�}|�t��|d|�Wd�n1sR0Y|�t|dd��qdS)Nc@seZdZdd�ZdS)z$MathTests.test_issue39871.<locals>.FcSsd|_dddS)NTrr)�	convertedrMrrrrN�sz.MathTests.test_issue39871.<locals>.F.__float__N)rOrPrQrNrrrrr=�sr=znot a numberr�F)r@r|r�rprarbr�r�)rKr=r�rrrr�test_issue39871�s(zMathTests.test_issue39871cCst�|�s|�d�|��dS)NzExpected a NaN, got {!r}.)r@rArXrrJrrrrr�s
zMathTests.assertIsNaNcCs,|�||�|�t�d|�t�d|��dS)zSimilar to assertEqual(), but compare also the sign with copysign().

        Function useful to compare signed zeros.
        r~N)r]r@r�)rKrrrrrr��szMathTests.assertEqualSignN)r<r=)LrOrPrQrZr_rjrlrnrprsrwr}r�rr�r��unittestZskipIfr�r��machiner�r�r�r�r�r�rZcpython_onlyr�r�r�r��HAVE_DOUBLE_ROUNDINGr�rr"r?rJrMrQrSrVrYZrequires_mac_verr[r^rcrfrirtrurwrxrzr|r}r�r�r�r�r�r�Z
skipUnlessrr�r�r�r�r�r�r�r�r�rrr�rrrrrW�s�


		=!
!�



�^*Jq5, 



	

	
		




8
B\@F
-
rWc@s�eZdZejZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) �IsCloseTestscOs0|j|j||g|�Ri|��d||fd�dS)Nz%s and %s should be close!�r�)rh�isclose�rKrrr��kwargsrrr�
assertIsClose�s
�zIsCloseTests.assertIsClosecOs0|j|j||g|�Ri|��d||fd�dS)Nz%s and %s should not be close!r�)r�r�r�rrr�assertIsNotClose�s
�zIsCloseTests.assertIsNotClosecOs,|D]"\}}|j||g|�Ri|��qdSrG)r��rKZexamplesr�r�rrrrr�assertAllClose�szIsCloseTests.assertAllClosecOs,|D]"\}}|j||g|�Ri|��qdSrG)r�r�rrr�assertAllNotClose�szIsCloseTests.assertAllNotClosecCsz|�t�� |jdddd�Wd�n1s00Y|�t��"|jddddd�Wd�n1sl0YdS)Nrg0��.�+���rel_tolr�g _�©r�r#)rardr�rMrrr�test_negative_tolerancess.z%IsCloseTests.test_negative_tolerancescCsgd�}|j|ddd�dS)N))r�r�)�N���@ir�)�;���r�)i90g��@)r=ry)�NFr�r=r��r�)rKZidentical_examplesrrr�test_identical
szIsCloseTests.test_identicalcCs(gd�}|j|dd�|j|dd�dS)N))g�חAg�חA)g:�0�yE�g��n�yE�)g�	ѭ��?gfN�ӭ��?�:�0�yE>r���&�.>�r�r�)rKZeight_decimal_places_examplesrrr�test_eight_decimal_placessz&IsCloseTests.test_eight_decimal_placescCs(gd�}|j|dd�|j|dd�dS)N))r�r=)g��&�.�r=)gu�?j�/ʠr=rdr�r�r�)r�r�)rKZnear_zero_examplesrrr�test_near_zeroszIsCloseTests.test_near_zerocCs<|�tt�|jttdd�|�tt�|jttdd�dS)Nr=r�)r�rerfrMrrr�test_identical_infinite&sz$IsCloseTests.test_identical_infinitecCsRttftdfdtfttfttfttftdfdtftdfdtfg
}|j|dd�dS)Nr�r~g������g�������?r�)rirerfr�)rKZnot_close_examplesrrr�test_inf_ninf_nan-s�zIsCloseTests.test_inf_ninf_nancCs0gd�}|j|dd�gd�}|j|dd�dS)N))r~r~)�333333�r�)�Y��n��r�r=r�))r~g�?)g�������?r~)gZb���tigTb���tir�)rKZzero_tolerance_close_examplesZ!zero_tolerance_not_close_examplesrrr�test_zero_tolerance<sz IsCloseTests.test_zero_tolerancecCs|jddgdd�dS)N)r#r�)r�r#r\r�r�rMrrr�test_asymmetryHszIsCloseTests.test_asymmetrycCs(ddg}|j|dd�|j|dd�dS)N)����)i�[i�[r�r�r�r�)rKZinteger_examplesrrr�
test_integersLs
�zIsCloseTests.test_integerscCshddlm}|d�|d�f|d�|d�f|d�|d�f|d	�|d
�fg}|j|dd�|j|d
d�dS)Nrrz
1.00000001z1.0z1.00000001e-20z1.0e-20z1.00000001e-100z1.0e-100z
1.00000001e20z1.0e20r�r�r�)r�r�r�r�)rKr�Zdecimal_examplesrrr�
test_decimalsTs�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�	rOr�r�r�)rr
r�r�)rKr
Zfraction_examplesrrr�test_fractions_s�zIsCloseTests.test_fractionsN)rOrPrQr@r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s 

r�cCsNddlm}t��}|�t�t��|�t�t��|�|d��t|�dS)Nr)�DocFileSuitezieee754.txt)	�doctestr�r�Z	TestSuiteZaddTestZ	makeSuiterWr�r)r�Zsuiterrr�	test_mainksr�)r<r=)8Ztest.supportrrr�testrr�r8r�r@�osr�r�rr�rgr,rirerfr�r�rr�rrrr�rO�argv�file�__file__�path�dirname�curdirZtest_dirr�r�r�rrrrr%r8r;rErFr?rRrIrTZTestCaserWr�r�rrrr�<module>sl&
-{


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists