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_cmath.cpython-39.opt-1.pyc

a

��gD`�@s�ddlmZmZddlmZmZddlmZddlZddlZddl	Z	ddlm
Z
mZmZm
Z
ddlZddlZed�Zed�Zdd�d	D�Zd
d�edfedfeefdefdefd
efdefeefedfedfed
fedfeefdefd
efdefdefeefedfed
ffD�Zdd�eefedfed
fedfedfeefeefdefd
efdefdefeeff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)������complex��.0�x�y�r�+/usr/local/lib/python3.9/test/test_cmath.py�
<listcomp>�rrcCsg|]\}}t||��qSrrrrrrrrr
�ffffff@r�ffffff�cCsg|]\}}t||��qSrrrrrrr%rc@seZdZdd�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�Zed6d7��Zed8d9��Zed:d;��ZdS)=�
CMathTestscCsg|]}tt|��qSr)�getattr�cmath)rZfnamerrrr6rzCMathTests.<listcomp>)�acos�acosh�asin�asinh�atan�atanh�cos�cosh�exp�log�log10�sin�sinh�sqrt�tan�tanhcCst�|d�S)Ny�@�rr'�rrrr�<lambda>;rzCMathTests.<lambda>cCst�d|�S)Ny,@;�r.r/rrrr0<rcCstt�|_dS�N)�openr�test_values��selfrrr�setUp>szCMathTests.setUpcCs|j��dSr1)r3�closer4rrr�tearDownAszCMathTests.tearDowncCs�d}t�|�st�|�r2t�|�rjt�|�rjdSn8||krj|dkrFdSt�d|�t�d|�krbdS|d7}|�|�||��dS)a#Fail unless floats x and y are identical, in the sense that:
        (1) both x and y are nans, or
        (2) both x and y are infinities, with the same sign, or
        (3) both x and y are zeros, with the same sign, or
        (4) x and y are both finite and nonzero, and x == y

        z&floats {!r} and {!r} are not identicalNr
��?z: zeros have different signs)�math�isnan�copysign�fail�format)r5rr�msgrrr�assertFloatIdenticalDszCMathTests.assertFloatIdenticalcCs$|�|j|j�|�|j|j�dS)z�Fail unless complex numbers x and y have equal values and signs.

        In particular, if x and y both have real (or imaginary) part
        zero, but the zeros have different signs, this test will fail.

        N)r@�real�imag)r5rrrrr�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�||��zt||�}Wnty�Yn0|t||t|��kr�dS|�|p�d�||��dS)a�Fail if the two floating-point numbers are not almost equal.

        Determine whether floating-point values a and b are equal to within
        a (small) rounding error.  The default values for rel_err and
        abs_err are chosen to be suitable for platforms where a float is
        represented by an IEEE 754 double.  They allow an error of between
        9 and 19 ulps.
        Nz{!r} should be nanz>finite result where infinity expected: expected {!r}, got {!r}r9z,zero has wrong sign: expected {!r}, got {!r}z({!r} and {!r} are not sufficiently close)	r:r;r=r>�isinfr<�abs�
OverflowError�max)r5�a�bZrel_err�abs_errr?Zabsolute_errorrrr�rAssertAlmostEquales0


��
�zCMathTests.rAssertAlmostEqualcCsHd}d}|jtj|dd�tj|�d�|jtj|dd�tj|�d�dS)NgiW�
�@g-DT�!	@�	zcmath.pi is {}; should be {})Zplacesr?zcmath.e is {}; should be {})�assertAlmostEqualrr	r>�e)r5Z
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)Nr
r
�infjr�nanj)�assertEqualrr
rAr:rBrR�
assertTruer;rrS�reprr4rrr�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�d�}Gdd�d�}	G��fdd�dt�}
G��fdd�d�}G�fdd�dt�}G�fdd �d �}
|jD�]*}|�||���|���|�||���|���|�||
��|���|�||��|���|�||��|���|�||
��|���|�||��|t|����|�t||��|�t||	��|�t||��|D]*}|�t|||��|�t|||���q�|��||��|��||���qdS)!Ny��z�@7Ă?�?g]�ֆ�znot complex���@c@seZdZdd�Zdd�ZdS)z.CMathTests.test_user_object.<locals>.MyComplexcSs
||_dSr1��value�r5r\rrr�__init__�sz7CMathTests.test_user_object.<locals>.MyComplex.__init__cSs|jSr1r[r4rrr�__complex__�sz:CMathTests.test_user_object.<locals>.MyComplex.__complex__N��__name__�
__module__�__qualname__r^r_rrrr�	MyComplex�srdc@seZdZdd�Zdd�ZdS)z0CMathTests.test_user_object.<locals>.MyComplexOScSs
||_dSr1r[r]rrrr^�sz9CMathTests.test_user_object.<locals>.MyComplexOS.__init__cSs|jSr1r[r4rrrr_�sz<CMathTests.test_user_object.<locals>.MyComplexOS.__complex__Nr`rrrr�MyComplexOS�srec@seZdZdS)z2CMathTests.test_user_object.<locals>.SomeExceptionN�rarbrcrrrr�
SomeException�srgcseZdZ�fdd�ZdS)z7CMathTests.test_user_object.<locals>.MyComplexExceptioncs��dSr1rr4�rgrrr_�szCCMathTests.test_user_object.<locals>.MyComplexException.__complex__N�rarbrcr_rrhrr�MyComplexException�srjcseZdZ�fdd�ZdS)z9CMathTests.test_user_object.<locals>.MyComplexExceptionOScs��dSr1rr4rhrrr_�szECMathTests.test_user_object.<locals>.MyComplexExceptionOS.__complex__Nrirrhrr�MyComplexExceptionOS�srkc@seZdZdS)z;CMathTests.test_user_object.<locals>.NeitherComplexNorFloatNrfrrrr�NeitherComplexNorFloat�srlc@seZdZdS)z=CMathTests.test_user_object.<locals>.NeitherComplexNorFloatOSNrfrrrr�NeitherComplexNorFloatOS�srmc@seZdZdd�Zdd�ZdS)z*CMathTests.test_user_object.<locals>.IndexcSsdS�N�rr4rrr�__int__�rz2CMathTests.test_user_object.<locals>.Index.__int__cSsdSrnrr4rrr�	__index__�rz4CMathTests.test_user_object.<locals>.Index.__index__N)rarbrcrprqrrrr�Index�srrc@seZdZdd�ZdS)z*CMathTests.test_user_object.<locals>.MyIntcSsdSrnrr4rrrrp�rz2CMathTests.test_user_object.<locals>.MyInt.__int__N)rarbrcrprrrr�MyInt�srscs$eZdZ�fdd�Z�fdd�ZdS)z4CMathTests.test_user_object.<locals>.FloatAndComplexcs�Sr1rr4��flt_argrr�	__float__�sz>CMathTests.test_user_object.<locals>.FloatAndComplex.__float__cs�Sr1rr4��cx_argrrr_�sz@CMathTests.test_user_object.<locals>.FloatAndComplex.__complex__N�rarbrcrvr_r�rxrurr�FloatAndComplex�sr{cs$eZdZ�fdd�Z�fdd�ZdS)z6CMathTests.test_user_object.<locals>.FloatAndComplexOScs�Sr1rr4rtrrrv�sz@CMathTests.test_user_object.<locals>.FloatAndComplexOS.__float__cs�Sr1rr4rwrrr_�szBCMathTests.test_user_object.<locals>.FloatAndComplexOS.__complex__Nryrrzrr�FloatAndComplexOS�sr|cseZdZ�fdd�ZdS)z.CMathTests.test_user_object.<locals>.JustFloatcs�Sr1rr4rtrrrv�sz8CMathTests.test_user_object.<locals>.JustFloat.__float__N�rarbrcrvrrtrr�	JustFloat�sr~cseZdZ�fdd�ZdS)z0CMathTests.test_user_object.<locals>.JustFloatOScs�Sr1rr4rtrrrv�sz:CMathTests.test_user_object.<locals>.JustFloatOS.__float__Nr}rrtrr�JustFloatOS�sr)�object�NotImplemented�	Exception�test_functionsrT�int�assertRaises�	TypeError)r5Z
non_complexesrdrerjrkrlrmrrrsr{r|r~r�fZbad_complexr)rgrxrur�test_user_object�sD
�zCMathTests.test_user_objectcCsV|jD]&}dD]}|�||�||����qq|jD]}dD]}|�t||�q<q4dS)N)rorZ)rJZlong_string�0Z1j�)r�rTrvr�r�)r5r��argrrr�test_input_types

zCMathTests.test_input_typecCsgd�}|dd�|D�gd�}|dgdd�|D�}dg|}dg|dd�|D�}|||||||||||||d	�
}|��D]N\}}tt|�}	tt|�}
|D],}|
|�}|�|	|�|j�|�d|j�q�q�d
D]>}
|D]4}t�||
�}|�t�||
�|j�|�d|j�q�q�dS)N)g{�G�z�?g�������?g�������?��?g�������?g�G�z��?cSsg|]
}|�qSrr�rrrrrr&rz6CMathTests.test_cmath_matches_math.<locals>.<listcomp>)r
r9��r9cSsg|]}d|�qS)r9rr�rrrr*rr
cSsg|]
}|�qSrrr�rrrr.r)
rr r"r$r%r&r'r(r)r*r+r,r-)r�rZg$@)	�itemsrr:rrMrArTrBr')r5r3Z
unit_intervalZpositiveZnonnegativeZ	real_liner��fn�valuesZfloat_fnZ
complex_fn�v�z�baserrr�test_cmath_matches_mathsB�
�

z"CMathTests.test_cmath_matches_mathcCs(dh}d}tjdkrLt��d}zttt|�d���}WntyJYn0dd�}dd�}tt	�D�]�\}}}}	}
}}t
||	�}
t
|
|�}|dur�|d	kr�||vr�qd|d
kr�|}n|dkr�|}n
tt|�}d|vs�d
|v�rz||
�}Wnt�yYqdYn0|�
d�||||	��d|v�r`z||
�}Wnt�yHYqdYn0|�
d�||||	��||
�}d|v�r�t
t|j�|j�}t
t|j�|j�}d|v�r�t
|jt|j��}t
|jt|j��}|dv�r�d}nd}d�||||	|j|j|j|j�}|j|j|j||d�|j|j|j|d�qddS)NZtan0064�darwinr�.cSst�|j|j�S)zaWrapped version of rect that accepts a complex number instead of
            two float arguments.)rrrArB�r�rrr�rect_complex\sz5CMathTests.test_specific_values.<locals>.rect_complexcSstt|��S)zYWrapped version of polar that returns a complex number instead of
            two floats.)rrr�rrr�
polar_complexasz6CMathTests.test_specific_values.<locals>.polar_complex)�
rYrrzdivide-by-zero�invalidz9ValueError not raised in test {}: {}(complex({!r}, {!r}))Zoverflowz<OverflowError not raised in test {}: {}(complex({!r}, {!r}))zignore-real-signzignore-imag-sign)r'r(rDrEz�{}: {}(complex({!r}, {!r}))
Expected: complex({!r}, {!r})
Received: complex({!r}, {!r})
Received value insufficiently close to expected value.)rLr?)r?)�sys�platformZmac_ver�tuple�mapr��split�
ValueErrorrrrrrr=r>rHrGrArBrM)r5Z
SKIP_ON_TIGERZosx_versionZversion_txtr�r��idr��arZaiZer�ei�flagsr��expected�function�actualZreal_abs_errZ
error_messagerrr�test_specific_valuesNsx




�

�


����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)Ncs,�|�}t||�D]\}}��||�qdSr1)�ziprM)r�r�ZgotrP�g��funcr5rr�check�sz%CMathTests.check_polar.<locals>.checkr)r
r
rX)r9r
���r9��?roy��g@r
r
�rY����r)r	�floatr)r5r�r�r
rrr�r�check_polar�s.

 zCMathTests.check_polarcCs|�t�dSr1)r�rr4rrr�
test_polar�szCMathTests.test_polarcs&ddlm��fdd�}|�|�dS)Nr��	set_errnocs*�d�zt|�W�d�S�d�0dS)N�r)rr�r�rr�polar_with_errno_set�s�z9CMathTests.test_polar_errno.<locals>.polar_with_errno_set)Z	_testcapir�r�)r5r�rr�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�tD]}|�t�	t|����q�dS)Nrr
r9r�y�Y��n�y�Y��n��r�roy��rrg�rr�g�?)
rOrr	rTr�INF�complex_nansrUr:r;�r5r�rrr�
test_phase�sBzCMathTests.test_phasecCs~tD]}|�t|�d�qtD]}|�t|�t�q|�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)Nr
rrr)
�
complex_zerosrTrG�complex_infinitiesr�r�NANrUr:r;r�rrr�test_abs�s"zCMathTests.test_abscCs|�tttdd��dS)Ng��U���)r�rHrGrr4rrr�test_abs_overflowsszCMathTests.test_abs_overflowscCsBd}t|j|d�|ks0t|j|d�|kr>|�||f�dS)NgH�����z>rrX)rGrArBr=)r5rJrKZepsrrr�assertCEquals,zCMathTests.assertCEqualcCsj|�tdd�d�|�tdd�d�|�tdt�d�|�tdtd�d�|�tdtd�d�dS)	Nr)rrrX)r9r)r�rro)rr9)rr�)r�rr	r4rrr�	test_rects
zCMathTests.test_rectcCsbtd�ddddtd�td�g}|D]:}|D]0}t||�}|�t�|�t�|�oVt�|��q*q"dS)Nz-infrrr
rr
r)r�rrTr�isfiniter:)r5Z	real_valsrrr�rrr�
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�NrXr�r)�assertFalserr;r�rUr�rr4rrr�
test_isnan,szCMathTests.test_isnancCs�|�t�d��|�t�d��|�t�t��|�t�t��|�t�ttd���|�t�tdt���|�t�ttt���|�t�ttt���|�t�ttt���dSr�)r�rrFr�rUr�rr4rrr�
test_isinf7szCMathTests.test_isinfcCs tD]}|�t�|�|�qdSr1)r�rCrr-r�rrr�testTanhSignBszCMathTests.testTanhSigncCs tD]}|�t�|�|�qdSr1)r�rCrr"r�rrr�testAtanSignKszCMathTests.testAtanSigncCs tD]}|�t�|�|�qdSr1)r�rCrr#r�rrr�
testAtanhSignPszCMathTests.testAtanhSign)rDrEN) rarbrcr��appendr6r8r@rCrMrQrWr�r�r�rr�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�rrrrr4sH
�
2b0
V
)
	

rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�IsCloseTestscCs�|�t�� |jdddd�Wd�n1s00Y|�t�� |jdddd�Wd�n1sj0Y|�t��"|jddddd�Wd�n1s�0YdS)Nr���rel_tol��abs_tol)r�r�)r�r��iscloser4rrr�test_reject_complex_tolerancesYs..z+IsCloseTests.test_reject_complex_tolerancescCs(gd�}|j|dd�|j|dd�dS)N))��?�?y��?�?)r�y�?��?)y��?y���?)y�?�y�?������g�-���q=r�g�vIh�%<=)�assertAllClose�assertAllNotClose)r5Zcomplex_examplesrrr�test_complex_valuescsz IsCloseTests.test_complex_valuescCsHgd�}|j|dd�|j|dd�|jdddd�|jdddd�dS)	N))y����MbP?r)���MbP?r)�����MbP?����MbP?r)y����MbP�����MbP?r)�����MbP?����MbP�r)y����MbP�����MbP�rg�~j�t�X?r�g����Mb@?r�r�g����Mb`?r�)r�r�Z
assertIsCloseZassertIsNotClose)r5Znear_zero_examplesrrr�test_complex_near_zerons
z#IsCloseTests.test_complex_near_zeroN)rarbrcrr�r�r�r�rrrrr�Vs
r��__main__)Ztest.supportrrZtest.test_mathrrZ	test_mathZunittestrr:rrrr	r�r�r�r�r�r�r�r�ZTestCaserr�ra�mainrrrr�<module>sl
��&)


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