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-2.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)Nz<qz<drl)�struct�unpack�pack)�x�n�r�*/usr/local/lib/python3.9/test/test_math.py�to_ulps's
rcCs|rdt||d@�SdS)N�r)�count_set_bits)rrrrrMsrcCsD||d?}|sdS|dkr |S||dB}t||�t||�SdS�Nr)�partial_product)�start�stopZ
numfactorsZmidrrrrQsrcCs`d}}tt|����D]6}|t||d?ddB||?ddB�9}||9}q||t|�>Sr)�reversed�range�
bit_lengthrr)r�innerZouter�irrr�py_factorial_s
*
rcCsLtt|�t|��}t||�}||ks0||kr4dSd}|�||||�SdS)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)N�--�->rr)�open�index�strip�split�float)�fname�fp�line�lhs�rhs�id�fn�arg�
rhs_pieces�exp�flagsrrr�parse_mtestfile|s	
r9c
	cs�t|���}|D]�}|�d�s|��s&q|�d�\}}|��\}}}}|��}	|	d|	d}
}|	dd�}||t|�t|�t|
�t|�|fVqWd�n1s�0YdS)Nr'r(rr�)r)�
startswithr+r,r-)
r.r/r0r1r2r3r4Zarg_realZarg_imagr6Zexp_realZexp_imagr8rrr�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)Nz	not equalzexpected {!r}, got {!r}z ({}))�
isinstancer-�int�math�isnan�isinfr&r )r!r"r#r$�failure�fail_fmtZfail_msgrrr�result_check�s&
rFc@seZdZdd�Zdd�ZdS)�	FloatLikecCs
||_dS�N��value��selfrJrrr�__init__�szFloatLike.__init__cCs|jSrHrI�rLrrr�	__float__�szFloatLike.__float__N)�__name__�
__module__�__qualname__rMrOrrrrrG�srGc@seZdZdS)�IntSubclassN�rPrQrRrrrrrS�srSc@seZdZdd�Zdd�ZdS)�MyIndexablecCs
||_dSrHrIrKrrrrM�szMyIndexable.__init__cCs|jSrHrIrNrrr�	__index__�szMyIndexable.__index__N�rPrQrRrMrVrrrrrU�srUc@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)Nz{}: {})rF�failr )rL�namer"r!r#r$rDrrr�ftest�s	zMathTests.ftestcCs8|�dtjd�|�dtjd�|�tjdtj�dS)N�pig-DT�!	@�egiW�
�@r:)r[rAr\r]�assertEqual�taurNrrr�
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�	TypeErrorrA�acosr[r\�
ValueError�INF�NINF�eps�
assertTruerB�NANrNrrr�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)rbrcrA�acoshr[rer^rfrgrirBrjrNrrr�	testAcosh
szMathTests.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)
rbrcrA�asinr[r\rerfrgrhrirBrjrNrrr�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)rag'�ya64�)rbrcrA�asinhr[r^rfrgrirBrjrNrrr�	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)ra�zatan(0)rzatan(1)rz	atan(inf)r:z
atan(-inf))rbrcrA�atanr[r\rfrgrirBrjrNrrr�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)rbrcrArsr[�atanhrerfrgrirBrjrNrrr�	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)rarr:zatan2(-1, 1)rrrzatan2(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.))rbrcrA�atan2r[r\rgr^rfrirBrjrNrrr�	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)Nrur��?��?r:rvr��ra���r>rzc@seZdZdd�ZdS)z$MathTests.testCeil.<locals>.TestCeilcSsdS�N�*rrNrrr�__ceil__�sz-MathTests.testCeil.<locals>.TestCeil.__ceil__N�rPrQrRr�rrrr�TestCeil�sr�c@seZdZdd�ZdS)z%MathTests.testCeil.<locals>.FloatCeilcSsdSr�rrNrrrr��sz.MathTests.testCeil.<locals>.FloatCeil.__ceil__Nr�rrrr�	FloatCeil�sr�c@seZdZdS)z&MathTests.testCeil.<locals>.TestNoCeilNrTrrrr�
TestNoCeil�sr�r�g@E@�+cWs|SrHr��argsrrr�<lambda>��z$MathTests.testCeil.<locals>.<lambda>)
rbrcrA�ceilr^r@�typer-rGr�)rLr�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�rr>i���r�r|�@�@rz���@)r^rA�copysignrbrcrfrgrirBrjrCrrNrrr�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)r:rr�r$zcos(0)z	cos(pi/2)zcos(pi)ra)
rbrcrA�cosr[r\�ulprirBrfrgrerjrNrrr�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)**2r:ra)rbrcrA�coshr[r^rfrgrirBrjrNrrr�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)rbrcrA�degreesr[r\rNrrr�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)r>�@B)
rbrcrAr7r[r]r^rfrgrirBrj�
OverflowErrorrNrrr�testExp�szMathTests.testExpcCsN|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�dS)Nzfabs(-1)rarzfabs(0)rzfabs(1))rbrcrA�fabsr[rNrrr�testFabs�szMathTests.testFabscCs�|�t�d�d�d}tdd�D]4}||9}|�t�|�|�|�t�|�t|��q |�ttjd�|�ttjdd�dS)Nrr��ra�
�d)r^rA�	factorialrrrbre)rL�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^rAr�rbrerc�decimal�DecimalrNrrr�testFactorialNonIntegers�s0...z"MathTests.testFactorialNonIntegerscCsR|�ttjdd�|�t�� |�ttjd�Wd�n1sD0YdS)Nr�r��}Ô%�I�T)rbr�rAr�r�r�rNrrr�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)Nrurrrr�rvrar�r����c@seZdZdd�ZdS)z&MathTests.testFloor.<locals>.TestFloorcSsdSr�rrNrrr�	__floor__sz0MathTests.testFloor.<locals>.TestFloor.__floor__N�rPrQrRr�rrrr�	TestFloorsr�c@seZdZdd�ZdS)z'MathTests.testFloor.<locals>.FloatFloorcSsdSr�rrNrrrr�sz1MathTests.testFloor.<locals>.FloatFloor.__floor__Nr�rrrr�
FloatFloorsr�c@seZdZdS)z(MathTests.testFloor.<locals>.TestNoFloorNrTrrrr�TestNoFloor!sr�r�g33333�D@�)cWs|SrHrr�rrrr�)r�z%MathTests.testFloor.<locals>.<lambda>)
rbrcrA�floorr^r@r�r-rGr�)rLr�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)ruz
fmod(10, 1.5)r�rzfmod(-10, 1)���rzzfmod(-10, 0.5)zfmod(-10, 1.5)r�r���)rbrcrA�fmodr[rirBrjrerfrgr^rNrrr�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!�mantr7ZemantZeexprNrr�	testfrexpFs
�z&MathTests.testFrexp.<locals>.testfrexpz	frexp(-1)ra)rvrzfrexp(0)r�rrzfrexp(1)r)rurzfrexp(2)r:)rur:)
rbrcrA�frexpr^rfrgrirBrj)rLr�rrNr�	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)Nr�r:rrr|)	rAr�r@�ldexp�max�len�binr�bool)�iterableZtmantZtexprr�r7�tail�h)�etiny�mant_digrr�msumhs
"(z MathTests.testFsum.<locals>.msumr>)r�rr��0��.�++g�d~�QJr�g�d~�Q�r�)�@Crvg��g������?C)r�r��9g@C)g@Crr�g@C)g������?Crug�<g������?CcSsg|]}d|�qS�rr��.0rrrr�
<listcomp>�r�z&MathTests.testFsum.<locals>.<listcomp>ri�z0x1.df11f45f4e61ap+2cSsg|]}d||�qS)r�rr�rrrr��r�z-0x1.62a2af1bd3624p-1)r	rg��ؗ�Ҝ<g��7y�AC)g��7y�ACg�������?g��7y�A�g�������cSs,g|]$}d|d|dd|d�qS)r��2�4rr�rrrr��r�����i�r:g�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�	enumeraterA�fsumr�rYrer^r�r�r�)rLr�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)Nrrrar�����r��T����� j9W P)�}� "o�`T"-� l�8P9�cC�/�[�N
S�9�b�Xl	9@{�wM�2�75�k )��	lZ��'^%#�>�;�*Q!/61^�f��^@�U@)rA�gcdr^rbrcrU)rLrr�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)r:Nr)r�r�rrr�	<genexpr>�r�z&MathTests.testHypot.<locals>.<genexpr>g(@r��*@r�r=�
r�r|r>�%��%@rrzr�ru�r皙�����?�string皙����@r�r�r�rr) r�r��	fractionsrrA�hypotr]r\�sqrt�gamma�sinrr��assertAlmostEqual�sumr^r�r�rbrcr�r��
max_10_exprer�rfrjrgrirB�	FLOAT_MAX�	FLOAT_MIN)rLr�rrr�r�int_too_big_for_float�	fourthmaxrr7�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)>Nrr	r
)rr�r�)r�r�r�r�)rr:r|)rrr:ra�	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)r:���rr,rr:r-r�)TTFTF)TFTTFr�)g�*@g)@g
�r>rr)rz)r>)r�r�ru)rrr)r�rur�c@seZdZdS)zMathTests.testDist.<locals>.TNrTrrrr�T_sr.)rrr=r)�p�q)r��r$)rrr)rr:r|rr)r=rr�)rrr=rr��abcZxyzr�)r:r|�rrzrr|)�repeatcSsg|]\}}||�qSrrr+rrrr��r�z&MathTests.testDist.<locals>.<listcomp>r�rr)r>r>)$r�r�rrrA�distrr^r�tuplerr�zip�iterr�rbrcrer�r�rr�r�rrgrfrj�	itertools�product�any�maprCrBrirr)rL�D�Fr5rrr�r/r0r.r �valuesZdiffsr!rr7r"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����(r:)r)r�r]rrrrr��r�z'MathTests.testIsqrt.<locals>.<listcomp>�<r�r|i'r�i�rIrraTFrc@seZdZdd�Zdd�ZdS)z(MathTests.testIsqrt.<locals>.IntegerLikecSs
||_dSrHrIrKrrrrM�sz1MathTests.testIsqrt.<locals>.IntegerLike.__init__cSs|jSrHrIrNrrrrV�sz2MathTests.testIsqrt.<locals>.IntegerLike.__index__NrWrrrr�IntegerLike�srCi�r����rza stringz3.5y@gY@r�)�listr�subTestrA�isqrt�assertIsr�r@�assertLessEqualZ
assertLessrbrer^�objectr�r�rc)rLr�rJr�rCZ
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)Nrrrar�r�r�iYr�r�iHr�r�r�l ,�`aUx�-�xB�:Vn
Ldbl�m�e%Y%l};T^�	)r�l�|/Kr2r�i�7rr)rA�lcmr^rbrcrU)rLrLrrrrr�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)r:zldexp(1,-1)raruzldexp(-1,1)r�rr�r�i���r>rz�i+���i��ld(	� F�x:^Vr�rA)rbrcrAr�r[r�r^rfrgrirBrj�rLrrrr�	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:r=zlog(10**40, 10)r�rAzlog(10**40, 10**20)rPz
log(10**1000)r�gO�+��@r�)
rbrcrA�logr[r]rergr^rfrirBrjrNrrr�testLogs�zMathTests.testLogcCsh|�ttj�dddddfD] }|�t�|�t�t|���q |�ttjd�|�t�t�t�dS)Nr:�Zi,ra)	rbrcrA�log1prr-rer^rfrQrrr�	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>r:rrrr�i�g��@�g�@i�g@�@r�)
rbrcrA�log2r^rergrirBrjrNrrr�testLog23szMathTests.testLog2r�cCs8dd�tdd�D�}dd�tdd�D�}|�||�dS)NcSsg|]}t�t�d|���qSr�)rArYr�r�rrrr�Jr�z+MathTests.testLog2Exact.<locals>.<listcomp>r�rXcSsg|]}t|��qSr�r-r�rrrr�Kr�)rr^)rLr�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)皙�����?razlog10(1)rrz	log10(10)r�zlog10(10**1000)r�g@�@r�)
rbrcrA�log10r[rergr^rSrfrirBrjrNrrr�	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�)rZr�r!Zv1Zv2�e1�e2rNrr�testmodf]s
�z$MathTests.testModf.<locals>.testmodfz	modf(1.5)r�)rurz
modf(-1.5)r�)rvr�r>rzrr)
rbrcrA�modfr^rfrgrjrirB)rLrbZmodf_nanrrNr�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)r:z	pow(2,-1)rarurr>r�r{r�rzg�ryr�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.rvz
(-2.)**-2.g�?z
(-2.)**-3.g��)rbrcrA�powr[r^rfrgrirBrjrerNrrr�testPowms�zMathTests.testPowcCsr|�ttj�|�dt�d�tj�|�dt�d�tjd�|�dt�d�tjd�|�d	t�d
�d
�dS)Nzradians(180)�zradians(90)rUr:zradians(-45)i���rrz
radians(0)r)rbrcrA�radiansr[r\rNrrr�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)Nr:)rIrr^r@)rr�rZfxZfy�frr�rrLrr�
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>rzr�ry)ryrzr>r{r{)rrrFr,r-r�rA�	remainderr^�hexrrjrgrf�assertIsNaNrbre)rLrnZ	testcasesroZx_hexZy_hexZexpected_hexrrr!r�Ztinyr�mrJrrmr�
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)r:rz
sin(-pi/2)ra)rbrcrArr[r\rirBrfrgrerjrNrrr�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)**2rr:razsinh(1)+sinh(-1))rbrcrA�sinhr[r�r^rfrgrirBrjrNrrr�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)rrr:ra)rbrcrArr[r^rfrergrirBrjrNrrr�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)rrrz
tan(-pi/4)ra)rbrcrA�tanr[r\rirBrfrgrerjrNrrr�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)rrar�z	tanh(inf)z
tanh(-inf))rbrcrA�tanhr[r�rfrgrirBrjrNrrr�testTanh�s�zMathTests.testTanhcCs8|�t�d�d�|�t�dt�d��t�dd��dS)Nrzr)r^rAr|r�rNrrr�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)Nrrar�r�g����?g�����g�!��rg-���?Y�i����c@seZdZdd�ZdS)z'MathTests.test_trunc.<locals>.TestTrunccSsdS�N�rrNrrr�	__trunc__�sz1MathTests.test_trunc.<locals>.TestTrunc.__trunc__N�rPrQrRr�rrrr�	TestTrunc�sr�c@seZdZdd�ZdS)z(MathTests.test_trunc.<locals>.FloatTrunccSsdSrrrNrrrr��sz2MathTests.test_trunc.<locals>.FloatTrunc.__trunc__Nr�rrrr�
FloatTrunc�sr�c@seZdZdS)z)MathTests.test_trunc.<locals>.TestNoTruncNrTrrrr�TestNoTrunc�sr�r�r:g�7@)	r^rA�truncr�r@r-rbrcrG)rLr�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>rzrr�rrr)rirA�isfinite�assertFalser-rNrrr�testIsfinite�szMathTests.testIsfinitecCsx|�t�td���|�t�td���|�t�td�d��|�t�td���|�t�d��|�t�d��dS)Nrz-nanrr>r)rirArBr-r�rNrrr�	testIsnan�szMathTests.testIsnancCs�|�t�td���|�t�td���|�t�d��|�t�d��|�t�td���|�t�d��|�t�d��dS)Nrrg�g�rr>r)rirArCr-r�rNrrr�	testIsinf�szMathTests.testIsinfcCs|�t�tj��dSrH)rirArBrrNrrr�test_nan_constant�szMathTests.test_nan_constantcCsJ|�t�tj��|�tjd�|�tjtd��|�tjtd��dS)Nr>rr)rirArCrZ
assertGreaterr^r-rNrrr�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)rAr7rYr�rre�rLrrrr�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-zerore�overflowr��r=r>zFailures in test_testfile:
  �
  )r��platformZmac_verr6r<r@r,rer<�	test_file�getattrrAr�rFr r�rY�join)rLZ
SKIP_ON_TIGERZosx_versionZversion_txtrE�failuresr3r4�arZaiZer�eir8�funcr�r#r$rD�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�rer�r�r�rr3�lgammagV瞯�<�erfcr>rr��$@r�r�zFailures in test_mtestfile:
  r�)r9�math_testcasesr�rArer�rFr r�rYr�)rLrEr�r3r4r5r!r8r�r"r#r$rDr�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=)rr:r1i�r�i_7)rr:r|rrr=r�)rr�r�r�r�r)rr:r|r�r�)rr�r�rrr=)rr�rrr�)rrr�rrr�)rrr��a�cr��br|�abZabababababab)rr:rr:rr:rr:rr:rr:r3)rrr:r|r)rrr:r|)rr:r|rcSs|D]}||9}q|SrHr)r�r�elemrrr�_naive_prod�s
z(MathTests.test_prod.<locals>._naive_prodi'i���rai���r�cSsg|]}t|��qSrr[�r�rrrrr��r�z'MathTests.test_prod.<locals>.<listcomp>cSsg|]}t|��qSrr[r�rrrr��r�cSsg|]}t|��qSrr[r�rrrr��r�rrrrDrr)rr:r|rrr=r)rr�r|rrr=rrr�r)r)rA�prodr^rErr8r-rbrc�	bytearrayrsr�r@r�r�)rLr�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�rrr3r�r�1r��10r|rar:r�T�Zcpython�)TT)TF)FFr=)rA�permr�rr^rbrcr�r�rer�check_impl_detailr�rHr�r@rSrU)rLr�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�rrr:r�rr�r�r�r|rar�Tr�r�r=)rA�combr�rr^rbrcr�r�rerr�r�rHr�r@rSrU)rLr�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��������rz0x1.fffffffffffffp-1z0x1.0000000000001p+0r�rz)r^rA�	nextafterrfr-r��assertEqualSignr�r��min�epsilonr�rsrj)rLZsmallest_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)	Nrl�lr�lg�@r>r)
r^rAr�r�r�r�r�rr�rfrsrrFr�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)�	convertedrNrrrrO�sz.MathTests.test_issue39871.<locals>.F.__float__N)rPrQrRrOrrrrr>�sr>znot a numberr�F)rAr}r�rqrbrcr�r�)rLr>r�rrrr�test_issue39871�s(zMathTests.test_issue39871cCst�|�s|�d�|��dS)NzExpected a NaN, got {!r}.)rArBrYr rKrrrrs�s
zMathTests.assertIsNaNcCs,|�||�|�t�d|�t�d|��dS)Nr)r^rAr�)rLrrrrrr��szMathTests.assertEqualSignN)r=r>)LrPrQrRr[r`rkrmrorqrtrxr~r�rr�r��unittestZskipIfr�r��machiner�r�r�r�r�r�rZcpython_onlyr�r�r�r��HAVE_DOUBLE_ROUNDINGr�rr#r@rKrNrRrTrWrZZrequires_mac_verr\r_rdrgrjrurvrxryr{r}r~r�r�r�r�r�r�Z
skipUnlessrr�r�r�r�r�r�r�r�r�rsr�rrrrrX�s�


		=!
!�



�^*Jq5, 



	

	
		




8
B\@F
-
rXc@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�)ri�isclose�rLrrr��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|��qdSrH)r��rLZexamplesr�r�rrrrr�assertAllClose�szIsCloseTests.assertAllClosecOs,|D]"\}}|j||g|�Ri|��qdSrH)r�r�rrr�assertAllNotClose�szIsCloseTests.assertAllNotClosecCsz|�t�� |jdddd�Wd�n1s00Y|�t��"|jddddd�Wd�n1sl0YdS)Nrg0��.�+���rel_tolr�g _�©r�r$)rbrer�rNrrr�test_negative_tolerancess.z%IsCloseTests.test_negative_tolerancescCsgd�}|j|ddd�dS)N))r�r�)�N���@ir�)�;���r�)i90g��@)r>rz)�NFr�r>r��r�)rLZidentical_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�)rLZeight_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>rer�r�r�)r�r�)rLZnear_zero_examplesrrr�test_near_zeroszIsCloseTests.test_near_zerocCs<|�tt�|jttdd�|�tt�|jttdd�dS)Nr>r�)r�rfrgrNrrr�test_identical_infinite&sz$IsCloseTests.test_identical_infinitecCsRttftdfdtfttfttfttftdfdtftdfdtfg
}|j|dd�dS)Nr�rg������g�������?r�)rjrfrgr�)rLZnot_close_examplesrrr�test_inf_ninf_nan-s�zIsCloseTests.test_inf_ninf_nancCs0gd�}|j|dd�gd�}|j|dd�dS)N))rr)�333333�r�)�Y��n��r�r>r�))rg�?)g�������?r)gZb���tigTb���tir�)rLZzero_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�rNrrr�test_asymmetryHszIsCloseTests.test_asymmetrycCs(ddg}|j|dd�|j|dd�dS)N)����)i�[i�[r�r�r�r�)rLZinteger_examplesrrr�
test_integersLs
�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�)rLr�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�	rPr�r�r�)rrr�r�)rLrZfraction_examplesrrr�test_fractions_s�zIsCloseTests.test_fractionsN)rPrQrRrAr�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	makeSuiterXr�r)r�Zsuiterrr�	test_mainksr�)r=r>)8Ztest.supportrrr�testrr�r9r�rA�osr�r�rr�rhr-rjrfrgr�r�rr�rrrr�rP�argv�file�__file__�path�dirname�curdirZtest_dirr�r�r�rrrrr&r9r<rFrGr@rSrJrUZTestCaserXr�r�rrrr�<module>sl&
-{


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