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: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_cmath.cpython-37.opt-2.pyc
B

��ga�@s�ddlmZmZddlmZmZddlmZddlZddlZddl	Z	ddlm
Z
mZmZm
Z
ddlZddlZddlZed�Zed�Zdd�d	D�Zd
d�edfedfeefdefdefd
efdefeefedfedfed
fedfeefdefd
efdefdefeefedfed
fgD�Zdd�eefedfed
fedfedfeefeefdefd
efdefdefeefgD�ZGdd�dej�ZGdd�dej�Zedk�r�e��dS)�)�requires_IEEE_754�cpython_only)�parse_testfile�	test_fileN)�phase�polar�rect�pi�inf�nancCs g|]}dD]}t||��qqS))gg�)�complex)�.0�x�y�r�+/usr/local/lib/python3.7/test/test_cmath.py�
<listcomp>sr)gg�cCsg|]\}}t||��qSr)r)r
rrrrrrsggffffff@g�gffffff�cCsg|]\}}t||��qSr)r)r
rrrrrr%sc@s.eZdZdd�dD�Ze�dd��e�dd��dd�Zd	d
�Zdd�Zd
d�Zd?dd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zd d!�Zd"d#�Zed$d%��Zd&d'�Zd(d)�Zed*d+��Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zee�e� d6�d7kd8�d9d:���Z!ed;d<��Z"ed=d>��Z#dS)@�
CMathTestscCsg|]}tt|��qSr)�getattr�cmath)r
Zfnamerrrr6szCMathTests.<listcomp>)�acosZacosh�asinZasinh�atan�atanh�cos�cosh�exp�log�log10�sin�sinh�sqrt�tan�tanhcCst�|d�S)Ny�@)rr)rrrr�<lambda>;�zCMathTests.<lambda>cCst�d|�S)Ny,@;�)rr)rrrrr$<r%cCstt�|_dS)N)�openr�test_values)�selfrrr�setUp>szCMathTests.setUpcCs|j��dS)N)r'�close)r(rrr�tearDownAszCMathTests.tearDowncCs�d}t�|�st�|�r2t�|�rjt�|�rjdSn8||krj|dkrFdSt�d|�t�d|�krbdS|d7}|�|�||��dS)Nz&floats {!r} and {!r} are not identicalgg�?z: zeros have different signs)�math�isnan�copysign�fail�format)r(rr�msgrrr�assertFloatIdenticalDszCMathTests.assertFloatIdenticalcCs$|�|j|j�|�|j|j�dS)N)r2�real�imag)r(rrrrr�assertComplexIdentical[sz!CMathTests.assertComplexIdentical�V瞯�<�
NcCs�t�|�r,t�|�rdS|�|p(d�|��t�|�rX||krBdS|�|pTd�||��|s�|s�t�d|�t�d|�kr�|�|p�d�||��yt||�}Wntk
r�YnX|t||t|��kr�dS|�|p�d�||��dS)Nz{!r} should be nanz>finite result where infinity expected: expected {!r}, got {!r}g�?z,zero has wrong sign: expected {!r}, got {!r}z({!r} and {!r} are not sufficiently close)	r,r-r/r0�isinfr.�abs�
OverflowError�max)r(�a�bZrel_err�abs_errr1Zabsolute_errorrrr�rAssertAlmostEquales*




zCMathTests.rAssertAlmostEqualcCsHd}d}|jtj|dd�tj|�d�|jtj|dd�tj|�d�dS)NgiW�
�@g-DT�!	@�	zcmath.pi is {}; should be {})Zplacesr1zcmath.e is {}; should be {})�assertAlmostEqualrr	r0�e)r(Z
e_expectedZpi_expectedrrr�test_constants�szCMathTests.test_constantscCs�|�tjjtj�|�tjjd�|�tjjd�|�tjjtj�|�t�tj	j��|�tj	jd�|�tj
jd�|�t�tj
j��|�ttj�d�|�ttj�d�|�ttj	�d�|�ttj
�d�dS)Ngr
�infjr�nanj)�assertEqualrr
r3r,r4rD�
assertTruer-rrE�repr)r(rrr�test_infinity_and_nan_constants�sz*CMathTests.test_infinity_and_nan_constantscs2d�d�dddddt�tg}Gdd�dt�}Gd	d
�d
�}Gdd�dt��G�fd
d�dt�}G�fdd�d�}Gdd�dt�}Gdd�d�}Gdd�dt�}Gdd�d�}	G��fdd�dt�}
G��fdd�d�}G�fdd�dt�}G�fdd �d �}
�x.|jD�]"}|�||���|���|�||���|���|�||
��|���|�||��|���|�||��|���|�||
��|���|�t||��|�t||��|�t||��|�t||	��x2|D]*}|�t|||��|�t|||���q�W|��||��|��||���qWdS)!Ny��z�@7Ă?�?g]�ֆ�znot complex��g@c@seZdZdd�Zdd�ZdS)z.CMathTests.test_user_object.<locals>.MyComplexcSs
||_dS)N)�value)r(rLrrr�__init__�sz7CMathTests.test_user_object.<locals>.MyComplex.__init__cSs|jS)N)rL)r(rrr�__complex__�sz:CMathTests.test_user_object.<locals>.MyComplex.__complex__N)�__name__�
__module__�__qualname__rMrNrrrr�	MyComplex�srRc@seZdZdd�Zdd�ZdS)z0CMathTests.test_user_object.<locals>.MyComplexOScSs
||_dS)N)rL)r(rLrrrrM�sz9CMathTests.test_user_object.<locals>.MyComplexOS.__init__cSs|jS)N)rL)r(rrrrN�sz<CMathTests.test_user_object.<locals>.MyComplexOS.__complex__N)rOrPrQrMrNrrrr�MyComplexOS�srSc@seZdZdS)z2CMathTests.test_user_object.<locals>.SomeExceptionN)rOrPrQrrrr�
SomeException�srTcseZdZ�fdd�ZdS)z7CMathTests.test_user_object.<locals>.MyComplexExceptioncs��dS)Nr)r()rTrrrN�szCCMathTests.test_user_object.<locals>.MyComplexException.__complex__N)rOrPrQrNr)rTrr�MyComplexException�srUcseZdZ�fdd�ZdS)z9CMathTests.test_user_object.<locals>.MyComplexExceptionOScs��dS)Nr)r()rTrrrN�szECMathTests.test_user_object.<locals>.MyComplexExceptionOS.__complex__N)rOrPrQrNr)rTrr�MyComplexExceptionOS�srVc@seZdZdS)z;CMathTests.test_user_object.<locals>.NeitherComplexNorFloatN)rOrPrQrrrr�NeitherComplexNorFloat�srWc@seZdZdS)z=CMathTests.test_user_object.<locals>.NeitherComplexNorFloatOSN)rOrPrQrrrr�NeitherComplexNorFloatOS�srXc@seZdZdd�Zdd�ZdS)z*CMathTests.test_user_object.<locals>.MyIntcSsdS)N�r)r(rrr�__int__�r%z2CMathTests.test_user_object.<locals>.MyInt.__int__cSsdS)NrYr)r(rrr�	__index__�r%z4CMathTests.test_user_object.<locals>.MyInt.__index__N)rOrPrQrZr[rrrr�MyInt�sr\c@seZdZdd�Zdd�ZdS)z,CMathTests.test_user_object.<locals>.MyIntOScSsdS)NrYr)r(rrrrZ�r%z4CMathTests.test_user_object.<locals>.MyIntOS.__int__cSsdS)NrYr)r(rrrr[�r%z6CMathTests.test_user_object.<locals>.MyIntOS.__index__N)rOrPrQrZr[rrrr�MyIntOS�sr]cs$eZdZ�fdd�Z�fdd�ZdS)z4CMathTests.test_user_object.<locals>.FloatAndComplexcs�S)Nr)r()�flt_argrr�	__float__�sz>CMathTests.test_user_object.<locals>.FloatAndComplex.__float__cs�S)Nr)r()�cx_argrrrN�sz@CMathTests.test_user_object.<locals>.FloatAndComplex.__complex__N)rOrPrQr_rNr)r`r^rr�FloatAndComplex�sracs$eZdZ�fdd�Z�fdd�ZdS)z6CMathTests.test_user_object.<locals>.FloatAndComplexOScs�S)Nr)r()r^rrr_�sz@CMathTests.test_user_object.<locals>.FloatAndComplexOS.__float__cs�S)Nr)r()r`rrrN�szBCMathTests.test_user_object.<locals>.FloatAndComplexOS.__complex__N)rOrPrQr_rNr)r`r^rr�FloatAndComplexOS�srbcseZdZ�fdd�ZdS)z.CMathTests.test_user_object.<locals>.JustFloatcs�S)Nr)r()r^rrr_�sz8CMathTests.test_user_object.<locals>.JustFloat.__float__N)rOrPrQr_r)r^rr�	JustFloat�srccseZdZ�fdd�ZdS)z0CMathTests.test_user_object.<locals>.JustFloatOScs�S)Nr)r()r^rrr_�sz:CMathTests.test_user_object.<locals>.JustFloatOS.__float__N)rOrPrQr_r)r^rr�JustFloatOS�srd)�object�NotImplemented�	Exception�test_functionsrF�assertRaises�	TypeError)r(Z
non_complexesrRrSrUrVrWrXr\r]rarbrcrd�fZbad_complexr)rTr`r^r�test_user_object�sB


zCMathTests.test_user_objectcCsfx4|jD]*}x$dD]}|�||�||����qWqWx*|jD] }xdD]}|�t||�qHWq>WdS)N)rYg@)r<Zlong_string�0Z1j�)rhrFr_rirj)r(rk�argrrr�test_input_types
 
zCMathTests.test_input_typecCs6ddddddg}|dd�|D�d	d
dg}|d
gdd�|D�}d	g|}d	g|d
d�|D�}|||||||||||||d�
}x^|��D]R\}}tt|�}	tt|�}
x4|D],}|
|�}|�|	|�|j�|�d	|j�q�Wq�WxJdD]B}
x<|D]4}t�||
�}|�t�||
�|j�|�d	|j�q�Wq�WdS)Ng{�G�z�?g�������?g�������?g�?g�������?g�G�z��?cSsg|]
}|�qSrr)r
rrrrr'sz6CMathTests.test_cmath_matches_math.<locals>.<listcomp>gg�?g�cSsg|]}d|�qS)g�?r)r
rrrrr+scSsg|]
}|�qSrr)r
rrrrr/s)
rrrrrrrrrr r!r"r#)g�?g@g$@)	�itemsrr,rr?r3rFr4r)r(r'Z
unit_intervalZpositiveZnonnegativeZ	real_linerh�fn�valuesZfloat_fnZ
complex_fn�v�z�baserrr�test_cmath_matches_maths>





z"CMathTests.test_cmath_matches_mathcCs0dh}d}tjdkrNt��d}yttt|�d���}Wntk
rLYnXdd�}dd�}�x�tt	�D�]�\}}}}	}
}}t
||	�}
t
|
|�}|dk	r�|d	kr�||kr�qj|d
kr�|}n|dkr�|}n
tt|�}d|ks�d
|k�r y||
�}Wntk
�rwjYnX|�
d�||||	��d|k�rfy||
�}Wntk
�rNwjYnX|�
d�||||	��||
�}d|k�r�t
t|j�|j�}t
t|j�|j�}d|k�r�t
|jt|j��}t
|jt|j��}|dk�r�d}nd}d�||||	|j|j|j|j�}|j|j|j||d�|j|j|j|d�qjWdS)NZtan0064�darwinr�.cSst�|j|j�S)N)rrr3r4)rurrr�rect_complex]sz5CMathTests.test_specific_values.<locals>.rect_complexcSstt|��S)N)rr)rurrr�
polar_complexbsz6CMathTests.test_specific_values.<locals>.polar_complex)�
rKrrzdivide-by-zeroZinvalidz9ValueError not raised in test {}: {}(complex({!r}, {!r}))Zoverflowz<OverflowError not raised in test {}: {}(complex({!r}, {!r}))zignore-real-signzignore-imag-sign)rrgV瞯�<g
z�{}: {}(complex({!r}, {!r}))
Expected: complex({!r}, {!r})
Received: complex({!r}, {!r})
Received value insufficiently close to expected value.)r>r1)r1)�sys�platformZmac_ver�tuple�map�int�split�
ValueErrorrrrrrr/r0r:r9r3r4r?)r(Z
SKIP_ON_TIGERZosx_versionZversion_txtrzr{�idrr�arZaiZerZei�flagsro�expectedZfunction�actualZreal_abs_errZ
error_messagerrr�test_specific_valuesOsl
 






zCMathTests.test_specific_valuescs���fdd�}|dd�|dd�|ddtf�|d	dtd
f�|ddtd
f�td
�}|t|d�|df�|t|d�|tf�|td|�|td
f�|td|�|td
f�|t||�|tdf�|t||�|tdf�|t||�|dtdf�|t||�|dtdf�td�}|t|d�||f�|td|�||f�|t||�||f�|t||�||f�|t||�||f�|t||�||f�|t||�||f�dS)Ncs0�|�}x"t||�D]\}}��||�qWdS)N)�zipr?)ror�ZgotrB�g)�funcr(rr�check�sz%CMathTests.check_polar.<locals>.checkr)ggrJ)g�?g���g�?y�?rYy��g@r
g�rK����r)r	�floatr)r(r�r�r
rr)r�r(r�check_polar�s.

 zCMathTests.check_polarcCs|�t�dS)N)r�r)r(rrr�
test_polar�szCMathTests.test_polarcs&ddlm��fdd�}|�|�dS)Nr)�	set_errnocs �d�zt|�S�d�XdS)N�r)r)ru)r�rr�polar_with_errno_set�sz9CMathTests.test_polar_errno.<locals>.polar_with_errno_set)Z	_testcapir�r�)r(r�r)r�r�test_polar_errno�szCMathTests.test_polar_errnocCs|�td�d�|�td�d�|�td�t�|�td�t�|�td�t�|�td�td�|�td	�td�|�ttdd��d�|�ttdd
��d
�|�ttd
d��t�|�ttd
d
��t�|�tttd
��t�|�tttd��t�|�tttt��dt�|�ttdt��td�|�ttd
t��td�|�ttdt��td�|�ttd
t��td�|�tttt��td�|�tttd��d
�|�tttd
��d
�|�tttd��d�|�tttd
��d�|�tttt��td�|�ttd
t��td�|�ttdt��td�|�ttd
t��td�|�ttdt��td�|�tttt��dt�|�tttd
��t�|�tttd��t�x"tD]}|�t�	t|����q�WdS)Nrgg�?g�y�Y��n�y�Y��n��y�?rYy��g�gffffff�g�gffffff@r�g�?)
rArr	rFr�INF�complex_nansrGr,r-)r(rurrr�
test_phase�sB
zCMathTests.test_phasecCs�xtD]}|�t|�d�qWxtD]}|�t|�t�q$W|�tttt��t�|�t�	tttd����|�t�	tttd����|�t�	tttd����|�t�	tttd����|�tttt��t�|�tttt��t�|�t�	ttdt����|�t�	ttdt����|�t�	ttdt����|�t�	ttdt����|�tttt��t�|�t�	tttt����dS)Nggffffff�g�gffffff@)
�
complex_zerosrFr9�complex_infinitiesr�r�NANrGr,r-)r(rurrr�test_abs�s"

zCMathTests.test_abscCs|�tttdd��dS)Ng��U���)rir:r9r)r(rrr�test_abs_overflowsszCMathTests.test_abs_overflowscCsBd}t|j|d�|ks0t|j|d�|kr>|�||f�dS)NgH�����z>rrJ)r9r3r4r/)r(r<r=Zepsrrr�assertCEquals,zCMathTests.assertCEqualcCsj|�tdd�d�|�tdd�d�|�tdt�d�|�tdtd�d�|�tdtd�d�dS)	Nr)rrrJ)g�?r)g�rrY)rg�?)rg�)r�rr	)r(rrr�	test_rects
zCMathTests.test_rectcCsjtd�ddddtd�td�g}xF|D]>}x8|D]0}t||�}|�t�|�t�|�oZt�|��q.Wq$WdS)Nz-infgffffff�g�ggffffff@r
r)r�rrFrZisfiniter,)r(Z	real_valsrrrurrr�
test_isfinite$s



zCMathTests.test_isfinitecCs�|�t�d��|�t�d��|�t�t��|�t�t��|�t�ttd���|�t�tdt���|�t�ttt���|�t�ttt���|�t�ttt���dS)NrJy�?r)�assertFalserr-r�rGr�r)r(rrr�
test_isnan-szCMathTests.test_isnancCs�|�t�d��|�t�d��|�t�t��|�t�t��|�t�ttd���|�t�tdt���|�t�ttt���|�t�ttt���|�t�ttt���dS)NrJy�?r)r�rr8r�rGr�r)r(rrr�
test_isinf8szCMathTests.test_isinfZTANH_PRESERVES_ZERO_SIGNrz,system tanh() function doesn't copy the signcCs$xtD]}|�t�|�|�qWdS)N)r�r5rr#)r(rurrr�testTanhSignCs
zCMathTests.testTanhSigncCs$xtD]}|�t�|�|�qWdS)N)r�r5rr)r(rurrr�testAtanSignNs
zCMathTests.testAtanSigncCs$xtD]}|�t�|�|�qWdS)N)r�r5rr)r(rurrr�
testAtanhSignSs
zCMathTests.testAtanhSign)r6r7N)$rOrPrQrh�appendr)r+r2r5r?rCrIrlrprwrr�r�r�rr�r�r�r�r�r�r�r�r��unittestZskipIf�	sysconfigZget_config_varr�r�r�rrrrr4s>

1c0W)		rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�IsCloseTestsc	Csx|�t��|jdddd�WdQRX|�t��|jdddd�WdQRX|�t��|jddddd�WdQRXdS)Ny�?)�rel_tol)�abs_tol)r�r�)rirj�isclose)r(rrr�test_reject_complex_tolerances\sz+IsCloseTests.test_reject_complex_tolerancescCs,ddddg}|j|dd�|j|dd�dS)N)y�?�?y��?�?)y�?�?y�?��?)y��?y���?)y�?�y�?������g�-���q=)r�g�vIh�%<=)�assertAllClose�assertAllNotClose)r(Zcomplex_examplesrrr�test_complex_valuesfsz IsCloseTests.test_complex_valuescCsPddddddg}|j|dd�|j|d	d�|jd
ddd�|jd
dd
d�dS)N)y����MbP?r)g����MbP?r)y����MbP?����MbP?r)y����MbP�����MbP?r)y����MbP?����MbP�r)y����MbP�����MbP�rg�~j�t�X?)r�g����Mb@?y����MbP?����MbP�y����MbP?����MbP?g����Mb`?g����MbP?)r�r�Z
assertIsCloseZassertIsNotClose)r(Znear_zero_examplesrrr�test_complex_near_zeroqsz#IsCloseTests.test_complex_near_zeroN)rOrPrQrr�r�r�r�rrrrr�Ys
r��__main__)Ztest.supportrrZtest.test_mathrrZ	test_mathr�rr,rrrr	r~r}r�r�r�r�r�r�r�ZTestCaserr�rO�mainrrrr�<module>sj
))