Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.147.45.11
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_cmath.cpython-310.pyc
o

`bV`�@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�Zedkr�e��dSdS)�)�requires_IEEE_754�cpython_only)�parse_testfile�	test_fileN)�phase�polar�rect�pi�inf�nancCs g|]}dD]}t||��qqS)������complex��.0�x�y�r�8/usr/local/python-3.10/lib/python3.10/test/test_cmath.py�
<listcomp>s rrcC�g|]	\}}t||��qSrrrrrrr�r
�ffffff@r�ffffff�cCrrrrrrrr%rc@seZdZdd�dD�Ze�dd��e�dd��dd�Zd	d
�Zdd�Zd
d�Z		d<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)rZfnamerrrr6szCMathTests.<listcomp>)�acos�acosh�asin�asinh�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,@;�r/r0rrrr1<r2cCsttdd�|_dS)Nzutf-8)�encoding)�openr�test_values��selfrrr�setUp>szCMathTests.setUpcCs|j��dS�N)r5�closer6rrr�tearDownA�zCMathTests.tearDowncCs�d}t�|�st�|�rt�|�rt�|�rdSn||kr5|dkr#dSt�d|�t�d|�kr1dS|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)r7rr�msgrrr�assertFloatIdenticalDs�zCMathTests.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)rD�real�imag)r7rrrrr�assertComplexIdentical[sz!CMathTests.assertComplexIdentical�V瞯�<�
NcCs�t�|�rt�|�rdS|�|pd�|��t�|�r,||kr!dS|�|p*d�||��|sG|sGt�d|�t�d|�krG|�|pEd�||��zt||�}Wn	tyXYnw|t||t|��krfdS|�|pod�||��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}r=z,zero has wrong sign: expected {!r}, got {!r}z({!r} and {!r} are not sufficiently close)	r>r?rArB�isinfr@�abs�
OverflowError�max)r7�a�bZrel_err�abs_errrCZabsolute_errorrrr�rAssertAlmostEquales2



�
��
�zCMathTests.rAssertAlmostEqualcCsHd}d}|jtj|dd�tj|�d�|jtj|dd�tj|�d�dS)NgiW�
�@g-DT�!	@�	zcmath.pi is {}; should be {})ZplacesrCzcmath.e is {}; should be {})�assertAlmostEqualrr	rB�e)r7Z
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
rEr>rFrV�
assertTruer?rrW�reprr6rrr�test_infinity_and_nan_constants�sz*CMathTests.test_infinity_and_nan_constantscs,d�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�|��||��|��||��q�dS)!Ny��z�@7Ă?�?g]�ֆ�znot complex���@c@�eZdZdd�Zdd�ZdS)z.CMathTests.test_user_object.<locals>.MyComplexcS�
||_dSr9��value�r7rbrrr�__init__��
z7CMathTests.test_user_object.<locals>.MyComplex.__init__cS�|jSr9rar6rrr�__complex__��z:CMathTests.test_user_object.<locals>.MyComplex.__complex__N��__name__�
__module__�__qualname__rdrgrrrr�	MyComplex��rmc@r_)z0CMathTests.test_user_object.<locals>.MyComplexOScSr`r9rarcrrrrd�rez9CMathTests.test_user_object.<locals>.MyComplexOS.__init__cSrfr9rar6rrrrg�rhz<CMathTests.test_user_object.<locals>.MyComplexOS.__complex__Nrirrrr�MyComplexOS�rnroc@�eZdZdS)z2CMathTests.test_user_object.<locals>.SomeExceptionN�rjrkrlrrrr�
SomeException��rrc�eZdZ�fdd�ZdS)z7CMathTests.test_user_object.<locals>.MyComplexExceptionc���r9rr6�rrrrrg��zCCMathTests.test_user_object.<locals>.MyComplexException.__complex__N�rjrkrlrgrrvrr�MyComplexException��rycrt)z9CMathTests.test_user_object.<locals>.MyComplexExceptionOScrur9rr6rvrrrg�rwzECMathTests.test_user_object.<locals>.MyComplexExceptionOS.__complex__Nrxrrvrr�MyComplexExceptionOS�rzr{c@rp)z;CMathTests.test_user_object.<locals>.NeitherComplexNorFloatNrqrrrr�NeitherComplexNorFloat�rsr|c@rp)z=CMathTests.test_user_object.<locals>.NeitherComplexNorFloatOSNrqrrrr�NeitherComplexNorFloatOS�rsr}c@r_)z*CMathTests.test_user_object.<locals>.IndexcS�dS�N�rr6rrr�__int__��z2CMathTests.test_user_object.<locals>.Index.__int__cSr~rrr6rrr�	__index__�r�z4CMathTests.test_user_object.<locals>.Index.__index__N)rjrkrlr�r�rrrr�Index�sr�c@seZdZdd�ZdS)z*CMathTests.test_user_object.<locals>.MyIntcSr~rrr6rrrr��r�z2CMathTests.test_user_object.<locals>.MyInt.__int__N)rjrkrlr�rrrr�MyInt�sr�c�$eZdZ�fdd�Z�fdd�ZdS)z4CMathTests.test_user_object.<locals>.FloatAndComplexc��Sr9rr6��flt_argrr�	__float__�rwz>CMathTests.test_user_object.<locals>.FloatAndComplex.__float__cr�r9rr6��cx_argrrrg�rwz@CMathTests.test_user_object.<locals>.FloatAndComplex.__complex__N�rjrkrlr�rgr�r�r�rr�FloatAndComplex��r�cr�)z6CMathTests.test_user_object.<locals>.FloatAndComplexOScr�r9rr6r�rrr��rwz@CMathTests.test_user_object.<locals>.FloatAndComplexOS.__float__cr�r9rr6r�rrrg�rwzBCMathTests.test_user_object.<locals>.FloatAndComplexOS.__complex__Nr�rr�rr�FloatAndComplexOS�r�r�crt)z.CMathTests.test_user_object.<locals>.JustFloatcr�r9rr6r�rrr��rwz8CMathTests.test_user_object.<locals>.JustFloat.__float__N�rjrkrlr�rr�rr�	JustFloat�rzr�crt)z0CMathTests.test_user_object.<locals>.JustFloatOScr�r9rr6r�rrr��rwz:CMathTests.test_user_object.<locals>.JustFloatOS.__float__Nr�rr�rr�JustFloatOS�rzr�)�object�NotImplemented�	Exception�test_functionsrX�int�assertRaises�	TypeError)r7Z
non_complexesrmroryr{r|r}r�r�r�r�r�r��fZbad_complexr)rrr�r�r�test_user_object�sF
�
�zCMathTests.test_user_objectcCsV|jD]}dD]}|�||�||����qq|jD]}dD]	}|�t||�qqdS)N)r�r^)rNZlong_string�0Z1j�)r�rXr�r�r�)r7r��argrrr�test_input_types
�
��zCMathTests.test_input_typecCsgd�}|dd�|D�gd�}|dgdd�|D�}dg|}dg|dd�|D�}|||||||||||||d	�
}|��D]'\}}tt|�}	tt|�}
|D]}|
|�}|�|	|�|j�|�d|j�qRqBd
D]}
|D]}t�||
�}|�t�||
�|j�|�d|j�qpqldS)N)g{�G�z�?g�������?g�������?��?g�������?g�G�z��?cS�g|]}|�qSrr�rrrrrr&�z6CMathTests.test_cmath_matches_math.<locals>.<listcomp>)r
r=��r=cSsg|]}d|�qS)r=rr�rrrr*sr
cSr�rrr�rrrr.r�)
rr!r#r%r&r'r(r)r*r+r,r-r.)r�r^g$@)	�itemsrr>rrQrErXrFr()r7r5Z
unit_intervalZpositiveZnonnegativeZ	real_liner��fn�valuesZfloat_fnZ
complex_fn�v�z�baserrr�test_cmath_matches_mathsH�
�

���z"CMathTests.test_cmath_matches_mathcCsdh}d}tjdkr&t��d}zttt|�d���}Wn	ty%Ynwdd�}dd�}tt	�D]�\}}}}	}
}}t
||	�}
t
|
|�}|durR|d	krR||vrRq2|d
krY|}n|dkr`|}ntt|�}d|vsmd
|vr�z||
�}Wn	ty|Yq2w|�
d�||||	��d|vr�z||
�}Wn	ty�Yq2w|�
d�||||	��||
�}d|vr�t
t|j�|j�}t
t|j�|j�}d|vr�t
|jt|j��}t
|jt|j��}|dvr�d}nd}d�||||	|j|j|j|j�}|j|j|j||d�|j|j|j|d�q2dS)NZtan0064�darwinr�.cSst�|j|j�S)zaWrapped version of rect that accepts a complex number instead of
            two float arguments.)rrrErF�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_complexasz6CMathTests.test_specific_values.<locals>.polar_complex)�
r]rrzdivide-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)rHrIz�{}: {}(complex({!r}, {!r}))
Expected: complex({!r}, {!r})
Received: complex({!r}, {!r})
Received value insufficiently close to expected value.)rPrC)rC)�sys�platformZmac_ver�tuple�mapr��split�
ValueErrorrrrrrrArBrLrKrErFrQ)r7Z
SKIP_ON_TIGERZosx_versionZversion_txtr�r��idr��arZaiZer�ei�flagsr��expected�function�actualZreal_abs_errZ
error_messagerrr�test_specific_valuesNs�
�


����
�����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]
\}}��||�q	dSr9)�ziprQ)r�r�ZgotrT�g��funcr7rr�check�s�z%CMathTests.check_polar.<locals>.checkr)r
r
r\)r=r
���r=��?r�y��g@r
r
�r]����r)r	�floatr)r7r�r�r
rrr�r�check_polar�s.

 zCMathTests.check_polarcCs|�t�dSr9)r�rr6rrr�
test_polar�r<zCMathTests.test_polarcs&ddlm��fdd�}|�|�dS)Nr��	set_errnocs&�d�z	t|�W�d�S�d�w)N�r)rr�r�rr�polar_with_errno_set�sz9CMathTests.test_polar_errno.<locals>.polar_with_errno_set)Z	_testcapir�r�)r7r�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|����qtdS)Nrr
r=r�y�Y��n�y�Y��n��r�r�y��rrg�rr�g�?)
rSrr	rXr�INF�complex_nansrYr>r?�r7r�rrr�
test_phase�sD�zCMathTests.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_zerosrXrK�complex_infinitiesr�r�NANrYr>r?r�rrr�test_abs�s"zCMathTests.test_abscCs|�tttdd��dS)Ng��U���)r�rLrKrr6rrr�test_abs_overflowsszCMathTests.test_abs_overflowscCsFd}t|j|d�|kst|j|d�|kr!|�||f�dSdS)NgH�����z>rr\)rKrErFrA)r7rNrOZepsrrr�assertCEquals,�zCMathTests.assertCEqualcCsj|�tdd�d�|�tdd�d�|�tdt�d�|�tdtd�d�|�tdtd�d�dS)	Nr)rrr\)r=r)r�rr�)rr=)rr�)r�rr	r6rrr�	test_rects
zCMathTests.test_rectcCsbtd�ddddtd�td�g}|D]}|D]}t||�}|�t�|�t�|�o+t�|��qqdS)Nz-infrrr
rr
r)r�rrXr�isfiniter>)r7Z	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�Nr\r�r)�assertFalserr?r�rYr�rr6rrr�
test_isnan,�zCMathTests.test_isnancCs�|�t�d��|�t�d��|�t�t��|�t�t��|�t�ttd���|�t�tdt���|�t�ttt���|�t�ttt���|�t�ttt���dSr�)r�rrJr�rYr�rr6rrr�
test_isinf7r�zCMathTests.test_isinfcC� tD]}|�t�|�|�qdSr9)r�rGrr.r�rrr�testTanhSignB��zCMathTests.testTanhSigncCr�r9)r�rGrr#r�rrr�testAtanSignKr�zCMathTests.testAtanSigncCr�r9)r�rGrr$r�rrr�
testAtanhSignPr�zCMathTests.testAtanhSign)rHrIN) rjrkrlr��appendr8r;rDrGrQrUr[r�r�r�rr�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�rrrrr4sJ

�2b0
V
)
	

rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�IsCloseTestscCs�|�t��|jdddd�Wd�n1swY|�t��|jdddd�Wd�n1s5wY|�t��|jddddd�Wd�dS1sTwYdS)Nr���rel_tol��abs_tol)r�r�)r�r��iscloser6rrr�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)r7Zcomplex_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)r7Znear_zero_examplesrrr�test_complex_near_zerons
z#IsCloseTests.test_complex_near_zeroN)rjrkrlrr�r�r�r�rrrrr�Vs

r��__main__)Ztest.supportrrZtest.test_mathrrZ	test_mathZunittestrr>rrrr	r�r�r�r�r�r�r�r�ZTestCaserr�rj�mainrrrr�<module>sp
��&)�
© 2025 GrazzMean