HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_math.cpython-310.opt-2.pyc
o

�i�j�@s�ddlmZmZmZddlmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZdZed�Zed�Zed�ZejjZejjZd\ZZeed	kZed
kr^ejdZneZe
j �!e�phe
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
kr�e7�dSdS),�)�run_unittest�verbose�requires_IEEE_754)�supportNg�h㈵��>�nan�inf�-inf)���7y�ACg�):��@g��7y�AC�__main__zmath_testcases.txtzcmath_testcases.txtcCs0	t�dt�d|��d}|dkr|d}|S)Nz<qz<drl)�struct�unpack�pack)�x�n�r�+/usr/local/lib/python3.10/test/test_math.py�to_ulps's


rcCs	|r
dt||d@�SdS)N�r)�count_set_bits)rrrrrMsrcCsB	||d?}|sdS|dkr|S||dB}t||�t||�S�Nr)�partial_product)�start�stopZ
numfactorsZmidrrrrQsrcCsb	d}}tt|����D]}|t||d?ddB||?ddB�9}||9}q
||t|�>Sr)�reversed�range�
bit_lengthrr)r�innerZouter�irrr�py_factorial_s*
rcCsJ	tt|�t|��}t||�}||ks||krdSd}|�||||�S)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|dd��H}|D]<}d|vr|d|�d��}|��sq|�d�\}}|��\}}}|��}|d}	|dd�}
||t|�t|	�|
fVqWd�dS1sSwYdS)N�utf-8��encoding�--�->rr)�open�index�strip�split�float)�fname�fp�line�lhs�rhs�id�fn�arg�
rhs_pieces�exp�flagsrrr�parse_mtestfile|s ��"�r<c
	cs��	t|dd��L}|D]@}|�d�s|��sq|�d�\}}|��\}}}}|��}	|	d|	d}
}|	dd�}||t|�t|�t|
�t|�|fVqWd�dS1sWwYdS)Nr'r(r*r+rr�)r,�
startswithr.r/r0)
r1r2r3r4r5r6r7Zarg_realZarg_imagr9Zexp_realZexp_imagr;rrr�parse_testfile�s$���"�r?��cCs�	||krdSd}t|t�rt|t�rt|�}nt|t�r&t|t�r&t|�}t|t�rOt|t�rOt�|�r=t�|�r=d}nt�|�sGt�|�rHnt||||�}|durdd}|�||�}|d�|�7}|SdS)Nz	not equalzexpected {!r}, got {!r}z ({}))�
isinstancer0�int�math�isnan�isinfr&r )r!r"r#r$�failure�fail_fmtZfail_msgrrr�result_check�s(
rIc@�eZdZdd�Zdd�ZdS)�	FloatLikecC�
||_dS�N��value��selfrOrrr�__init__��
zFloatLike.__init__cC�|jSrMrN�rQrrr�	__float__��zFloatLike.__float__N)�__name__�
__module__�__qualname__rRrVrrrrrK��rKc@�eZdZdS)�IntSubclassN�rXrYrZrrrrr]��r]c@rJ)�MyIndexablecCrLrMrNrPrrrrR�rSzMyIndexable.__init__cCrTrMrNrUrrr�	__index__�rWzMyIndexable.__index__N�rXrYrZrRrarrrrr`�r[r`c@s�eZdZd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�Ze�ejdkoCe��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$e
e�e!d9�d:d;���Z%d<d=�Z&d>d?�Z'd@dA�Z(dBdC�Z)dDdE�Z*dFdG�Z+dHdI�Z,e
dJdK��Z-e
e�.dLd�dMdN���Z/dOdP�Z0dQdR�Z1dSdT�Z2dUdV�Z3e
dWdX��Z4dYdZ�Z5d[d\�Z6d]d^�Z7d_d`�Z8dadb�Z9e
dcdd��Z:dedf�Z;dgdh�Z<didj�Z=dkdl�Z>e
dmdn��Z?e
dodp��Z@e�AeBdq�drds��ZCe
dtdu��ZDe
dvdw��ZEdxdy�ZFdzd{�ZGd|d}�ZHe
d~d��ZIe
d�d���ZJd�d��ZKd�d��ZLd�d��ZMd�S)��	MathTestsr@rAcCs2	t||||�}|dur|�d�||��dSdS)Nz{}: {})rI�failr )rQ�namer"r!r#r$rGrrr�ftest�s
�zMathTests.ftestcCs8|�dtjd�|�dtjd�|�tjdtj�dS)N�pig-DT�!	@�egiW�
�@r=)rfrDrgrh�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�	TypeErrorrD�acosrfrg�
ValueError�INF�NINF�eps�
assertTruerE�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�?rl)rmrnrD�acoshrfrprirqrrrtrErurUrrr�	testAcosh
szMathTests.testAcoshcCs�|�ttj�|�dt�d�tjd�|�dt�d�d�|�dt�d�tjd�|�ttjt�|�ttjt�|�ttjdt	�|�ttjdt	�|�
t�t�t���dS)Nzasin(-1)rlr=zasin(0)rzasin(1)r)
rmrnrD�asinrfrgrprqrrrsrtrErurUrrr�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)rlg'�ya64�)rmrnrD�asinhrfrirqrrrtrErurUrrr�	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)rl�zatan(0)rzatan(1)rz	atan(inf)r=z
atan(-inf))rmrnrD�atanrfrgrqrrrtrErurUrrr�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��rrl)rmrnrDr~rf�atanhrprqrrrtrErurUrrr�	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)rlrr=zatan2(-1, 1)rr}zatan2(0, 1)zatan2(1, 1)zatan2(1, 0)zatan2(0., -inf)rAzatan2(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.))rmrnrD�atan2rfrgrrrirqrtrErurUrrr�	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)Nr�r��?��?r=r�r��rl���rAr�c@�eZdZdd�ZdS)z$MathTests.testCeil.<locals>.TestCeilcS�dS�N�*rrUrrr�__ceil__��z-MathTests.testCeil.<locals>.TestCeil.__ceil__N�rXrYrZr�rrrr�TestCeil��r�c@r�)z%MathTests.testCeil.<locals>.FloatCeilcSr�r�rrUrrrr��r�z.MathTests.testCeil.<locals>.FloatCeil.__ceil__Nr�rrrr�	FloatCeil�r�r�c@r\)z&MathTests.testCeil.<locals>.TestNoCeilNr^rrrr�
TestNoCeil�r_r�r�g@E@�+cW�|SrMr��argsrrr�<lambda>��z$MathTests.testCeil.<locals>.<lambda>)
rmrnrD�ceilrirC�typer0rKr�)rQr�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�rAi���r�r��@�@r����@)rirD�copysignrmrnrqrrrtrErurFrrUrrr�testCopysign�s0zMathTests.testCopysigncCs|�ttj�|jdt�tjd�dt�d�d�|�dt�d�d�|jdt�tjd�dt�d�d�|�dt�tj�d	�z|�t�t�t	���|�t�t�t
���Wntyr|�ttjt	�|�ttjt
�Ynw|�t�t�t���dS)
Nz
cos(-pi/2)r=rr�r$zcos(0)z	cos(pi/2)zcos(pi)rl)
rmrnrD�cosrfrg�ulprtrErqrrrprurUrrr�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=rl)rmrnrD�coshrfrirqrrrtrErurUrrr�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)r}g�F�z
degrees(0)r)rmrnrD�degreesrfrgrUrrr�testDegrees��
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)rlrzexp(0)rzexp(1)rA�@B)
rmrnrDr:rfrhrirqrrrtrEru�
OverflowErrorrUrrr�testExp�szMathTests.testExpcCsN|�ttj�|�dt�d�d�|�dt�d�d�|�dt�d�d�dS)Nzfabs(-1)rlrzfabs(0)rzfabs(1))rmrnrD�fabsrfrUrrr�testFabs�szMathTests.testFabscCs�|�t�d�d�d}tdd�D]}||9}|�t�|�|�|�t�|�t|��q|�ttjd�|�ttjdd�dS)Nrr��rl�
�d)rirD�	factorialrrrmrp)rQ�totalrrrr�
testFactorial�szMathTests.testFactorialcCs�|�ttjd�|�ttjd�|�ttjd�|�ttjd�|�ttjt�d��|�ttjt�d��|�ttjd�dS)N�@g������@r��}Ô%�I���5z5.2)rmrnrDr��decimal�DecimalrUrrr�testFactorialNonIntegers�sz"MathTests.testFactorialNonIntegerscCs(|�ttjdd�|�ttjd�dS)Nr�r��}Ô%�I�T)rmr�rDr�rnrUrrr�testFactorialHugeInputssz!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)Nr�rr�rr�r�rlr�r����c@r�)z&MathTests.testFloor.<locals>.TestFloorcSr�r�rrUrrr�	__floor__r�z0MathTests.testFloor.<locals>.TestFloor.__floor__N�rXrYrZr�rrrr�	TestFloorr�r�c@r�)z'MathTests.testFloor.<locals>.FloatFloorcSr�r�rrUrrrr�r�z1MathTests.testFloor.<locals>.FloatFloor.__floor__Nr�rrrr�
FloatFloorr�r�c@r\)z(MathTests.testFloor.<locals>.TestNoFloorNr^rrrr�TestNoFloorr_r�r�g33333�D@�)cWr�rMrr�rrrr�$r�z%MathTests.testFloor.<locals>.<lambda>)
rmrnrD�floorrirCr�r0rKr�)rQr�r�r�r�rrr�	testFloor	s&
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�rrAz
fmod(10, 0.5)r�z
fmod(10, 1.5)r�r�zfmod(-10, 1)���r�zfmod(-10, 0.5)zfmod(-10, 1.5)r�r���)rmrnrD�fmodrfrtrErurprqrrrirUrrr�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)NcsF||\}}\}}t||�tks||kr!��d|||f�dSdS�Nz%s returned %r, expected %r�rrsrd)re�resultr!�mantr:ZemantZeexprUrr�	testfrexpAs
��z&MathTests.testFrexp.<locals>.testfrexpz	frexp(-1)rl)r�rzfrexp(0)r�rrzfrexp(1)r)r�rzfrexp(2)r=)r�r=)
rmrnrD�frexprirqrrrtrEru)rQr�rrUr�	testFrexp>szMathTests.testFrexpz2fsum is not exact on machines with double roundingcs.ddlm}|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]9\}\}}zt	�
|�}Wn%ty�|�d#|||f�Ynt
y�|�d$|||f�Ynw|�||�q�dd%lm}m}	m}
td"�D]7}gd&�d'}d}td(�D]}|	d|��d)|}
||
7}|�|
�q�|
|�||�}|�||�t	�
|��q�dS)*Nr)�
float_infocs�	d\}}|D]-}t�|�\}}tt�|���|�}}||kr*|||K}|}n|||K}||7}qtttt|���d��|�}|dkrhd|d>}|d|t||@oa|d|d@�}||7}t�||�S)Nr�r=rrr�)	rDr�rC�ldexp�max�len�binr�bool)�iterableZtmantZtexprr�r:�tail�h)�etiny�mant_digrr�msumcs 
"(z MathTests.testFsum.<locals>.msumrA)r�r�r��0��.�++g�d~�QJr�g�d~�Q�r�)�@Cr�g��g������?C)r�r���9g@C)g@Cr�r�g@C)g������?Cr�g�<g������?CcSsg|]}d|�qS�r�r��.0rrrr�
<listcomp>��z&MathTests.testFsum.<locals>.<listcomp>ri�z0x1.df11f45f4e61ap+2cSsg|]}d||�qS)r�rr�rrrr���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��s,����i�r=g�z0x1.5555555555555p+970cSsg|]}d|�qS)g333333�?r�r�rrrrr��r�cs g|]}�|d�|�qS�rrr�)�termsrrr��s 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_exprr0�fromhex�append�	enumeraterD�fsumr�rdrprir�r�r�)rQr�r��test_valuesrZvalsr!�actualr�r�r��j�s�vr)r�r�r�r�testFsumPsn





��

��� �
�
���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]Z}||}||}|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�ql|�|�d�|�|d�d�|�|d
�d�|�|ddd�d�|�|ddd�d�|�t|d�|�t|dd�|�t|dd�|�t|ddd�|�|td�td��d	�dS)Nrrrlr������x�T����� j9W P)�}� "o�`T"-� l�8P9�cC�/�[�N
S�9�b�Xl	9@{�wM�2�75�k )��	lZ��'^%#�>�;�*Q!/61^�f��^@�U@)rD�gcdrirmrnr`)rQrr�y�c�a�brrr�testGcd�sN��zMathTests.testGcdcCs�ddlm}ddlm}tj}tjtjt�d�t�	d�t�
d�f}tt|�d�D]}|�
||d|��t�tdd	�|d|�D����q)|�|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�n1s�wY|�t��|ddd�Wd�n1s�wYdtjjd}|�ttf��
|d|�Wd�n	1�swY|�|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]}|�t�||g|�|t�|����q�td�D]}	t d|	}
|�t�d |
d|
�d|
��q�dS)!Nr�r���Fractionr��@g������@rcss�|]}|dVqdS)r=Nr)r�rrrr�	<genexpr>�s�z&MathTests.testHypot.<locals>.<genexpr>g(@r��*@rr@�
rr�rA�%��%@r�r�r�r��r皙�����?�string皙����@r�r�r�r})!r�r��	fractionsrrD�hypotrhrg�sqrt�gamma�sinrr��assertAlmostEqual�sumrir�r�rmrnr�r��
max_10_exprpr�rqrurrrtrE�	FLOAT_MAX�isclose�	FLOAT_MIN)rQr�rr)r�r�int_too_big_for_float�	fourthmaxrr:�scalerrr�	testHypot�sx$�$,�

����
�$�zMathTests.testHypotz7hypot() loses accuracy on machines with double roundingc	
Cs�tj}tj}tjdd�}dD]U\}}t�|�}t�|�}|j||||d��6t�|��t||�d||�d�	��}Wd�n1sFwY|�
|||�|�Wd�n1s^wYqdS)Ni�)Zprec))z0x1.10e89518dca48p+29z0x1.1970f7565b7efp+30)z0x1.10106eb4b44a2p+29z0x1.ef0596cdc97f8p+29)z0x1.459c058e20bb7p+30z0x1.993ca009b9178p+29)z0x1.378371ae67c0cp+30z0x1.fbe6619854b4cp+29)z0x1.f4cd0574fb97ap+29z0x1.50fe31669340ep+30)z0x1.494b2cdd3d446p+29z0x1.212a5367b4c7cp+29)z0x1.f84e649f1e46dp+29z0x1.1fa56bef8eec4p+30)z0x1.2e817edd3d6fap+30z0x1.eb0814f1e9602p+29)z0x1.0d3a6e3d04245p+29z0x1.32a62fea52352p+30)z0x1.888e19611bfc5p+29z0x1.52b8e70b24353p+29)z0x1.538816d48a13fp+29z0x1.7967c5ca43e16p+29)z0x1.57b47b7234530p+29z0x1.74e2c7040e772p+29)z0x1.821b685e9b168p+30z0x1.677dc1c1e3dc6p+29)z0x1.9e8247f67097bp+29z0x1.24bd2dc4f4baep+29)z0x1.b73b59e0cb5f9p+29z0x1.da899ab784a97p+28)z0x1.94a8d2842a7cfp+30z0x1.326a51d4d8d8ap+30)z0x1.e930b9cd99035p+29z0x1.5a1030e18dff9p+30)z0x1.1592bbb0e4690p+29z0x1.a9c337b33fb9ap+29)z0x1.1243a50751fd4p+29z0x1.a5a10175622d9p+29)z0x1.57a8596e74722p+30z0x1.42d1af9d04da9p+30)z0x1.ee7dbd9565899p+29z0x1.7ab4d6fc6e4b4p+29)z0x1.5c6bfbec5c4dcp+30z0x1.02511184b4970p+30)z0x1.59dcebba995cap+30z0x1.50ca7e7c38854p+29)z0x1.768cdd94cf5aap+29z0x1.9cfdc5571d38ep+29)z0x1.dcf137d60262ep+29z0x1.1101621990b3ep+30)z0x1.3a2d006e288b0p+30z0x1.e9a240914326cp+29)z0x1.62a32f7f53c61p+29z0x1.47eb6cd72684fp+29)z0x1.d3bcb60748ef2p+29z0x1.3f13c4056312cp+30)z0x1.282bdb82f17f3p+30z0x1.640ba4c4eed3ap+30)z0x1.89d8c423ea0c6p+29z0x1.d35dcfe902bc3p+29)�hx�hyrrr=)rDr)r�r�ZContextr0r��subTestZlocalcontextr*ri)	rQr)r�Zhigh_precisionr7r8rr�zrrr�testHypotAccuracy&s
%
"����zMathTests.testHypotAccuracycCsddlm}ddlm}tj}tj}|�|dd�d�|�|dd�d�td	�D]4}td
�D]-}t	dd�t|�D��}t	d
d�t|�D��}|�
|||�|tdd�t||�D����q.q(|�|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�n	1�s-wY|�t��|d�Wd�n	1�sGwY|�t��|dd(d*�Wd�n	1�scwY|�t��
|dd�Wd�n	1�s~wY|�t��
|d+d�Wd�n	1�s�wY|�t��
|d,d-�Wd�n	1�s�wY|�t��
|dd.�Wd�n	1�s�wY|�t��
|d/d0�Wd�n	1�s�wYd1tjjd
}
|�ttf��|d|
fd2�Wd�n	1�swY|�ttf��|d2d|
f�Wd�n	1�s0wYtd3�D]}t��t��}}|�||f|f�t||���q9td4d5dd6ttg}tj|d7d8�D]@}tj|d7d8�D]5}d9d:�t||�D�}tttj|���r�|�|||�t��qntttj |���r�|�!t� |||����qn�qet"d;}
td�D].}|
f|}d"|}|�!t�#|||�|
t�|���|�!t�#|||�|
t�|����q�td�D]+}t$d|}d<|d7|f}d=}|�t�||�d
|�|�t�||�d
|��q�dS)>Nrrr)r�r�r�)r�r�r�r�)rr=r�)r}r=rl�	r@cs��|]	}t�dd�VqdS����r@N�r��uniform�r��krrrrt��z%MathTests.testDist.<locals>.<genexpr>csr=r>r@rBrrrrurDcss �|]\}}||dVqdS)r�Nr�r�ZpxZqxrrrrxs�)g,@r�)r�r�r )�r)r=���r!rFrr=rGr)TTFTF)TFTTFr�)g�*@g)@g
�rArr�)r�)rA)r�r�r�)rrr)r�r�r�c@r\)zMathTests.testDist.<locals>.TNr^rrrr�T�r_rH)r}r@r)�p�q)r��r<)r%r&r')rr=r�r})r@rr�)r}r@rr��abcZxyzr�)r=r��r"r�r#r�)�repeatcSsg|]\}}||�qSrrrErrrr��r�z&MathTests.testDist.<locals>.<listcomp>r�r})rArA)%r�r�r(rrD�distr*rir�tupler-r.�zip�iterr�rmrnrpr�r�r/r�r�rrrrqru�	itertools�product�any�maprFrErtr0r1r2)rQ�D�FrOr*rrrIrJrHr3�valuesZdiffsr4rr:r5rrr�testDistes���	".,���������
���������"��

"&�zMathTests.testDistcCsD|�t��t�ddggd��Wd�dS1swYdS)Nrr=)r�r}r@)rmrprDrOrUrrr�test_math_dist_leak�s"�zMathTests.test_math_dist_leakc
Cs.ttd��ttdd��dd�tdd�D�dd	d
dg}|D]9}|j|d��)t�|�}|�t|�t�|�|||�|�	||d
|d
�Wd�n1sUwYq!|�
t��
t�d�Wd�n1spwYt�d�}|�t|�t�|�|d
�t�d�}|�t|�t�|�|d�Gdd�dt
�}t�|d��}|�t|�t�|�|d�|�
t��t�|d��Wd�n1s�wYddt�d�dddg}|D]3}|j|d��"|�
t��
t�|�Wd�n1s�wYWd�n	1�swYq�dS)Nr�iX>i(FcSs(g|]}tdd�D]}d||�q	qS)i����(r=)r)r�rhrrrrr��s(z'MathTests.testIsqrt.<locals>.<listcomp>�<r�r�i'r�i�rNrrlTFrc@rJ)z(MathTests.testIsqrt.<locals>.IntegerLikecSrLrMrNrPrrrrR�rSz1MathTests.testIsqrt.<locals>.IntegerLike.__init__cSrTrMrNrUrrrra�rWz2MathTests.testIsqrt.<locals>.IntegerLike.__index__Nrbrrrr�IntegerLike�r[r^i�r����rza stringz3.5y@gY@r�)�listrr9rD�isqrt�assertIsr�rC�assertLessEqualZ
assertLessrmrpri�objectr�r�rn)rQrrOrr^Z
bad_valuesrrr�	testIsqrt�sX
����
���

�������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]`}||}||}|||}|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�|�|||�|�ql|�|�d�|�|d�d�|�|d�d�|�|dd	d�d�|�|ddd	�d�|�t|d�|�t|dd	�|�t|dd�|�t|ddd�|�|td�td	��d
�dS)Nrrrlr�rriYr	r
iHrr
rl ,�`aUx�-�xB�:Vn
Ldbl�m�e%Y%l};T^�	)rl�|/Kr2ri�7rr)rD�lcmrirmrnr`)rQrfrrrrr�drrr�test_lcmsP��zMathTests.test_lcmc	Cs6|�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]�}|�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|���q�dS)Nz
ldexp(0,1)rrz
ldexp(1,1)r=zldexp(1,-1)rlr�zldexp(-1,1)r�r�r�r�i���rAr��i+���i��ld(	� F�x:^Vr�r\)rmrnrDr�rfr�rirqrrrtrEru�rQrrrr�	testLdexp<s8�zMathTests.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)rrlzlog(1)rzlog(e)z	log(32,2)rr=r@zlog(10**40, 10)r�r\zlog(10**40, 10**20)rjz
log(10**1000)r�gO�+��@r�)
rmrnrD�logrfrhrprrrirqrtrErurUrrr�testLog\s�zMathTests.testLogcCsh|�ttj�dddddfD]}|�t�|�t�t|���q|�ttjd�|�t�t�t�dS)Nr=�Zi,rl)	rmrnrD�log1pr-r0rprirqrkrrr�	testLog1pls
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)NrrAr=r�r}r�i�g��@�g�@i�g@�@r�)
rmrnrD�log2rirprrrtrErurUrrr�testLog2sszMathTests.testLog2r�cCs8dd�tdd�D�}dd�tdd�D�}|�||�dS)NcSsg|]}t�t�d|���qSr�)rDrsr�r�rrrr��sz+MathTests.testLog2Exact.<locals>.<listcomp>r�rrcS�g|]}t|��qSr�r0r�rrrr��r�)rri)rQrr!rrr�
testLog2Exact�szMathTests.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)皙�����?rlzlog10(1)rrz	log10(10)r�zlog10(10**1000)r�g@�@r�)
rmrnrD�log10rfrprrrirmrqrtrErurUrrr�	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)
NcsJ||\}}\}}t||�tkst||�r#��d|||f�dSdSr�r�)rer�r!Zv1Zv2�e1�e2rUrr�testmodf�s
��z$MathTests.testModf.<locals>.testmodfz	modf(1.5)r�)r�r�z
modf(-1.5)r�)r�r�rAr�rr)
rmrnrD�modfrirqrrrurtrE)rQr}Zmodf_nanrrUr�testModf�s
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)rlr�r�rAr�r�r�r�g�r�r�r�g.�g�������gffffff�?r%��������?rxg��������g�������g�������gffffff��z	(-2.)**3.g �z	(-2.)**2.r�z	(-2.)**1.z	(-2.)**0.z
(-2.)**-0.z
(-2.)**-1.r�z
(-2.)**-2.g�?z
(-2.)**-3.g��)rmrnrD�powrfrirqrrrtrErurprUrrr�testPow�s�zMathTests.testPowcCsr|�ttj�|�dt�d�tj�|�dt�d�tjd�|�dt�d�tjd�|�d	t�d
�d
�dS)Nzradians(180)�zradians(90)ror=zradians(-45)i���r}z
radians(0)r)rmrnrD�radiansrfrgrUrrr�testRadiansBr�zMathTests.testRadiansc	s�ddlm���fdd�}gd�}|D]D}�j|d��4|��\}}}t�|�}t�|�}t�|�}	||||	�t�||�}
��|
�	�|	�	��Wd�n1sRwYqt�d�}t
dd	�D]0}|dkriqb||}t
d
�D] }
|
|}t�||�}
||||
�t�||�}
||||
�qqqbtddd
dtt
fD]}��t�t|����t�|t��q�dD]}��t�|t
�|���t�|t�|�q�tddddt
fD]q}��t��t�t
|�Wd�n1s�wY��t��t�t|�Wd�n	1�swY��t��t�|d�Wd�n	1�s"wY��t��t�|d�Wd�n	1�s>wYq�dS)Nrrcs�	�|��|��|�}}}��t|�t|d��|||}��|t|��t|�t|d�krA��|dt|d��dSdS)Nr=)rcrrirC)rr�rZfxZfy�frr�rrQrr�
validate_specMs�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�rAr�r�r�)r�r�rAr�r�)r(rr9r/r0r�rD�	remainderri�hexrrurrrq�assertIsNaNrmrp)rQr�Z	testcasesr�Zx_hexZy_hexZexpected_hexrrr!rZtinyr�mrOrr�r�
testRemainderIs^;


��
�	������zMathTests.testRemaindercCs�|�ttj�|�dt�d�d�|�dt�tjd�d�|�dt�tjd�d�z|�t�t�t���|�t�t�t	���Wnt
y]|�t
tjt�|�t
tjt	�Ynw|�t�t�t���dS)Nzsin(0)rz	sin(pi/2)r=rz
sin(-pi/2)rl)rmrnrDr,rfrgrtrErqrrrprurUrrr�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=rlzsinh(1)+sinh(-1))rmrnrD�sinhrfr�rirqrrrtrErurUrrr�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)r}r=rl)rmrnrDr*rfrirqrprrrtrErurUrrr�testSqrt�szMathTests.testSqrtcCs�|�ttj�|�dt�d�d�|�dt�tjd�d�|�dt�tjd�d�z|�t�t�t���|�t�t�t	���Wn|�t
tjt�|�t
tjt	�Y|�t�t�t���dS)Nztan(0)rz	tan(pi/4)r}rz
tan(-pi/4)rl)rmrnrD�tanrfrgrtrErqrrrprurUrrr�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)rrlr�z	tanh(inf)z
tanh(-inf))rmrnrD�tanhrfr�rqrrrtrErurUrrr�testTanh�s�zMathTests.testTanhcCs8|�t�d�d�|�t�dt�d��t�dd��dS)Nr�r�)rirDr�r�rUrrr�testTanhSigns
�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)Nrrlr�r�g����?g�����g�!��rg-���?Y�i����c@r�)z'MathTests.test_trunc.<locals>.TestTrunccSr��N�rrUrrr�	__trunc__r�z1MathTests.test_trunc.<locals>.TestTrunc.__trunc__N�rXrYrZr�rrrr�	TestTruncr�r�c@r�)z(MathTests.test_trunc.<locals>.FloatTrunccSr�r�rrUrrrr�r�z2MathTests.test_trunc.<locals>.FloatTrunc.__trunc__Nr�rrrr�
FloatTruncr�r�c@r\)z)MathTests.test_trunc.<locals>.TestNoTruncNr^rrrr�TestNoTruncr_r�r�r=g�7@)	rirD�truncr�rCr0rmrnrK)rQr�r�r�rrr�
test_truncs&zMathTests.test_trunccCs�|�t�d��|�t�d��|�t�d��|�t�d��|�t�td���|�t�td���|�t�td���dS)NrAr�r�r�rrr)rtrD�isfinite�assertFalser0rUrrr�testIsfinite$szMathTests.testIsfinitecCsx|�t�td���|�t�td���|�t�td�d��|�t�td���|�t�d��|�t�d��dS)Nrz-nanrrAr�)rtrDrEr0r�rUrrr�	testIsnan-szMathTests.testIsnancCs�|�t�td���|�t�td���|�t�d��|�t�d��|�t�td���|�t�d��|�t�d��dS)Nrrg�g�rrAr�)rtrDrFr0r�rUrrr�	testIsinf5szMathTests.testIsinfcCs|�t�tj��dSrM)rtrDrErrUrrr�test_nan_constant>�zMathTests.test_nan_constantcCsJ|�t�tj��|�tjd�|�tjtd��|�tjtd��dS)NrArr)rtrDrFrZ
assertGreaterrir0rUrrr�test_inf_constantBszMathTests.test_inf_constantzrequires verbose modecCs�zt�d�}Wn	|�d�Y|dkr|�d�zt�d�}Wn	ty*Ynw|�d�zt�d�}Wn
tyAYdSw|�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)rDr:rdr�r*rp�rQrrrr�test_exceptionsNs$
�
�zMathTests.test_exceptionsc	Csddh}d}tjdkr&t��d}zttt|�d���}Wn	ty%Ynwd}g}tt	�D]s\}}}}	}
}}|	dks?|dkr@q.|dvrEq.|durR|dkrR||vrRq.t
t|�}
d	|vs_d
|vrbd}
nd|vrhd
}
z|
|�}Wntyyd}Ynty�d
}Ynwd\}}t
|
|||�}|dur�q.|�||||�}|�|�q.|r�|�dd�|��dSdS)NZtan0064�darwinr�.�{}: {}({!r}): {}rA)ZrectZpolar)r�r@�invalid�divide-by-zerorp�overflowr��r@rAzFailures in test_testfile:
  �
  )r��platformZmac_verrPrVrCr/rpr?�	test_file�getattrrDr�rIr r�rd�join)rQZ
SKIP_ON_TIGERZosx_versionZversion_txtrH�failuresr6r7�arZaiZer�eir;�funcr�r#r$rG�msgrrr�
test_testfilensT
�
�
��zMathTests.test_testfilec	Cs*d}g}tt�D]|\}}}}}tt|�}d|vsd|vrd}nd|vr%d}z||�}	Wnty6d}	Ynty@d}	Ynwd\}
}|dkrLd	}
n|d
krSd}n|dkrk|d
krk|dkrbd}
n	|dkrid}
nd}
t||	|
|�}|durwq|�||||�}
|�|
�q|r�|�	dd�
|��dSdS)Nr�r�r�rpr�r�r�r+rM�lgammagV瞯�<�erfcrAr�r��$@r�r�zFailures in test_mtestfile:
  r�)r<�math_testcasesr�rDrpr�rIr r�rdr�)rQrHr�r6r7r8r!r;r�r"r#r$rGr�rrr�test_mtestfile�sH
�
��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�n	1�s3wY|�|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=rKi�r�i_7)rr=r�r}r@r	)r�r�r�r�r�r)rr=r�r�r�)r�r�r�r}r@)rr�rrr�)r�r�r�rrr�)rrr��a�c��br��abZabababababab)rr=rr=rr=rr=rr=rr=rM)rrr=r�r)rrr=r�)rr=r�rcSs|D]}||9}q|SrMr)r�r�elemrrr�_naive_prods
z(MathTests.test_prod.<locals>._naive_prodi'i���rli���r�cSrurrv�r�rrrrr�$r�z'MathTests.test_prod.<locals>.<listcomp>cSrurrvr�rrrr�&r�cSrurrvr�rrrr�(r�rrrr_r})rr=r�r}r@r)rr�r�r}r@rr�r�rr�)rD�prodrir`rrRr0rmrn�	bytearrayr�r�rCr�r�)rQr�rYr�r�rrr�	test_prod�s�  �



$$   �zMathTests.test_prodc	CsLtj}tj}td�D]}t|d�D]}|�|||�||�|||��qq
tdd�D]#}td|�D]}|�|||�||d|d�|||d|��q3q,tdd�D]}|�||d�d�|�||d�|�|�|||�||��qUtd�D]}|�||�||��|�||d�||��qy|�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��rH|�t|||�dD]\}}|�|||�d�|�
t|||��t��qJ|�|td�td��d�|�|td�td��d�td
�D]!}|�
t|td�t|���t�|�
t|td�t|���t��q�dS)Nr�rrrMr�r��1r��10r�rlr=r�T�Zcpython�)TT)TF)FFr@)rD�permr�rrirmrnr�r�rpr�check_impl_detailr�rbr�rCr]r`)rQr�r�rrCrrr�testPermFsb��4�"�zMathTests.testPermc
Cs�tj}tj}td�D] }t|d�D]}|�|||�||�||�|||��qq
tdd�D]!}td|�D]}|�|||�||d|d�||d|��q7q0td�D]}|�||d�d�|�|||�d�qVtdd�D]}|�||d�|�|�|||d�|�qptd�D]}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]\}}|�|||�d�|�
t|||��t��q�|�|td�td��d�|�|td�td��d�td
�D]!}|�
t|td�t|���t�|�
t|td�t|���t��q�dS)Nr�rrr=r�r�r�r�r�r�rlr�Tr�r�r@)rD�combr�rrirmrnr�r�rprr�r�rbr�rCr]r`)rQr�r�rrCrrr�testComb�sn��0��""�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�CrAg�������Cg��g��������r�z0x1.fffffffffffffp-1z0x1.0000000000001p+0r�r�)rirD�	nextafterrqr0r��assertEqualSignr�r��min�epsilonr�r�ru)rQZsmallest_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|d��|�t�|�t�|��Wd�n1s~wYq^dS)	Nr�l�lr�lg�@rAr$)
rirDr�r�r�r�r�r0r�rqr�rr9r�rrr�test_ulp�s$�����zMathTests.test_ulpc	CstGdd�d�}tjtjtjfD](}|�}|�t��
|d|�Wd�n1s)wY|�t|dd��qdS)Nc@r�)z$MathTests.test_issue39871.<locals>.FcSsd|_dddS)NTrr)�	convertedrUrrrrVsz.MathTests.test_issue39871.<locals>.F.__float__N)rXrYrZrVrrrrrXr�rXznot a numberr�F)rDr�r�r�rmrnr�r�)rQrXr�rrrr�test_issue39871s��zMathTests.test_issue39871cCs"t�|�s|�d�|��dSdS)NzExpected a NaN, got {!r}.)rDrErdr rPrrrr�#s
�zMathTests.assertIsNaNcCs.	|�||�|�t�d|�t�d|��dS)Nr�)rirDr�)rQrrrrrr�'s zMathTests.assertEqualSignNr�)NrXrYrZrfrkrvrxrzr|rr�r�r�rr�r��unittestZskipIfr�r��machiner�r�r�r�r�r�rZcpython_onlyr�r�r�r��HAVE_DOUBLE_ROUNDINGrrr6r;rZr[rerhrlrnrqrtZrequires_mac_verrwrzrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Z
skipUnlessrr�r�r�r�r�r�r�r�r�r�r�rrrrrc�s�


		=!
!�




�^*K�<q5, 



	

	
		




8
B\@F
-
rcc@s�eZdZejZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) �IsCloseTestscO�0|j|j||g|�Ri|��d||fd�dS)Nz%s and %s should be close!�r�)rtr1�rQrrr��kwargsrrr�
assertIsClose3�

�zIsCloseTests.assertIsClosecOr�)Nz%s and %s should not be close!r�)r�r1r�rrr�assertIsNotClose7r�zIsCloseTests.assertIsNotClosecO�,|D]\}}|j||g|�Ri|��qdSrM)r��rQZexamplesr�r�rrrrr�assertAllClose;��zIsCloseTests.assertAllClosecOr�rM)r�r�rrr�assertAllNotClose?r�zIsCloseTests.assertAllNotClosecCs||�t��|jdddd�Wd�n1swY|�t��|jddddd�Wd�dS1s7wYdS)Nrg0��.�+���rel_tolr�g _�©r�r$)rmrpr�rUrrr�test_negative_tolerancesCs�"�z%IsCloseTests.test_negative_tolerancescCsgd�}|j|ddd�dS)N))r�r�)�N���@ir�)�;���r�)i90g��@)rAr�)�NFr�rAr��r�)rQZidentical_examplesrrr�test_identicalJszIsCloseTests.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�)rQZeight_decimal_places_examplesrrr�test_eight_decimal_placesTsz&IsCloseTests.test_eight_decimal_placescCs(gd�}|j|dd�|j|dd�dS)N))r�rA)g��&�.�rA)gu�?j�/ʠrAr�r�r�r�)r�r�)rQZnear_zero_examplesrrr�test_near_zero\szIsCloseTests.test_near_zerocCs<|�tt�|jttdd�|�tt�|jttdd�dS)NrAr�)r�rqrrrUrrr�test_identical_infinitefsz$IsCloseTests.test_identical_infinitecCsRttftdfdtfttfttfttftdfdtftdfdtfg
}|j|dd�dS)Nr�r�g������g�������?r�)rurqrrr�)rQZnot_close_examplesrrr�test_inf_ninf_nanms�zIsCloseTests.test_inf_ninf_nancCs0gd�}|j|dd�gd�}|j|dd�dS)N))r�r�)�333333�r)�Y��n��rrAr�))r�g�?)g�������?r�)gZb���tigTb���tir�)rQZzero_tolerance_close_examplesZ!zero_tolerance_not_close_examplesrrr�test_zero_tolerance|sz IsCloseTests.test_zero_tolerancecCs|jddgdd�dS)N)r<r�)r�r<rxr�r�rUrrr�test_asymmetry�r�zIsCloseTests.test_asymmetrycCs(ddg}|j|dd�|j|dd�dS)N)����)i�[i�[r�r�r�r�)rQZinteger_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)Nrrz
1.00000001z1.0z1.00000001e-20z1.0e-20z1.00000001e-100z1.0e-100z
1.00000001e20z1.0e20r�r�r�)r�r�r�r�)rQr�Zdecimal_examplesrrr�
test_decimals�s�zIsCloseTests.test_decimalscCsdddlm}|dd�d|d�f|d�|d�f|dd�|dd�fg}|j|dd	�|j|d
d	�dS)Nrrrrrl �	(q�e�	rjr�r�r�)r(rr�r�)rQrZfraction_examplesrrr�test_fractions�s�zIsCloseTests.test_fractionsN)rXrYrZrDr1r�r�r�r�r�r�r�r�rrrrrr	r
rrrrr�0s"

r�cCsNddlm}t��}|�t�t��|�t�t��|�|d��t|�dS)Nr)�DocFileSuitezieee754.txt)	�doctestrr�Z	TestSuiteZaddTestZ	makeSuitercr�r)rZsuiterrr�	test_main�sr
r�)8Ztest.supportrrr�testrr�rSr�rD�osr�r�rr�rsr0rurqrrr�r�r0r�r2rrr�rX�argv�file�__file__�path�dirname�curdirZtest_dirr�r�r�rrrrr&r<r?rIrKrCr]rdr`ZTestCasercr�r
rrrr�<module>sp&
-Q{
�