HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/test/__pycache__/test_cmath.cpython-36.pyc
3


 \a�@s�ddlmZmZddlmZmZddljZddlZddlZddl	Z	ddlm
Z
mZmZm
Z
ddlZddlZddlZed�Zed�Zdd�dD�Zd
d�ed	fedfeefdefd	efdefdefeefedfed	fedfedfeefdefdefd	efdefeefedfedfgD�Zdd�eefedfedfed	fedfeefeefdefdefd	efdefeefgD�ZGd
d�dej�ZGdd�dej�Zedk�r�ej�dS) �)�requires_IEEE_754�cpython_only)�parse_testfile�	test_fileN)�phase�polar�rect�pi�inf�nancCs g|]}dD]}t||��qqS)���)rr
)�complex)�.0�x�y�r�"/usr/lib64/python3.6/test_cmath.py�
<listcomp>sr�cCsg|]\}}t||��qSr)r)rrrrrrrsgffffff@cCsg|]\}}t||��qSr)r)rrrrrrr%sc@s.eZdZdd�dND�Zejdd��ejdd��dd�Zdd�Zdd�Zdd�ZdOd!d"�Z	d#d$�Z
d%d&�Zd'd(�Zd)d*�Z
d+d,�Zed-d.��Zd/d0�Zd1d2�Zed3d4��Zd5d6�Zd7d8�Zed9d:��Zd;d<�Zd=d>�Zd?d@�ZdAdB�ZdCdD�Zeejej dE�dFkdG�dHdI���Z!edJdK��Z"edLdM��Z#d S)P�
CMathTestscCsg|]}tt|��qSr)�getattr�cmath)rZfnamerrrr6szCMathTests.<listcomp>�acos�acosh�asin�asinh�atan�atanh�cos�cosh�exp�log�log10�sin�sinh�sqrt�tan�tanhcCstj|d�S)Ng�@yy�@)rr")rrrr�<lambda>;szCMathTests.<lambda>cCstjd|�S)Ng,@y;@y,@;�)rr")rrrrr)<scCstt�|_dS)N)�openr�test_values)�selfrrr�setUp>szCMathTests.setUpcCs|jj�dS)N)r+�close)r,rrr�tearDownAszCMathTests.tearDowncCs�d}tj|�stj|�r2tj|�rjtj|�rjdSn8||krj|dkrFdStjd|�tjd|�krbdS|d7}|j|j||��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 identicalNgg�?z: zeros have different signs)�math�isnan�copysign�fail�format)r,rr�msgrrr�assertFloatIdenticalDszCMathTests.assertFloatIdenticalcCs$|j|j|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)r6�real�imag)r,rrrrr�assertComplexIdentical[sz!CMathTests.assertComplexIdentical�V瞯�<�
NcCs�tj|�r,tj|�rdS|j|p(dj|��tj|�rX||krBdS|j|pTdj||��|r�|r�tjd|�tjd|�kr�|j|p�dj||��yt||�}Wntk
r�YnX|t||t|��kr�dS|j|p�dj||��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}g�?z,zero has wrong sign: expected {!r}, got {!r}z({!r} and {!r} are not sufficiently close)	r0r1r3r4�isinfr2�abs�
OverflowError�max)r,�a�bZrel_err�abs_errr5Zabsolute_errorrrr�rAssertAlmostEquales*




zCMathTests.rAssertAlmostEqualcCsHd}d}|jtj|ddjtj|�d�|jtj|ddjtj|�d�dS)NgiW�
�@g-DT�!	@�	zcmath.pi is {}; should be {})Zplacesr5zcmath.e is {}; should be {})�assertAlmostEqualrr	r4�e)r,Z
e_expectedZpi_expectedrrr�test_constants�szCMathTests.test_constantscCs�|jtjjtj�|jtjjd�|jtjjd�|jtjjtj�|jtjtj	j��|jtj	jd�|jtj
jd�|jtjtj
j��|jttj�d�|jttj�d�|jttj	�d�|jttj
�d�dS)Ngr
�infjr�nanj)�assertEqualrr
r7r0r8rH�
assertTruer1rrI�repr)r,rrr�test_infinity_and_nan_constants�sz*CMathTests.test_infinity_and_nan_constantscs2d"�d#�dddddt�tg}Gdd	�d	t�}Gd
d�d�}Gdd
�d
t��G�fdd�dt�}G�fdd�d�}Gdd�dt�}Gdd�d�}Gdd�dt�}Gdd�d�}	G��fdd�dt�}
G��fdd�d�}G�fdd�dt�}G�fd d!�d!�}
�x.|jD�]"}|j||���|���|j||���|���|j||
��|���|j||��|���|j||��|���|j||
��|���|jt||��|jt||��|jt||��|jt||	��x2|D]*}|jt|||��|jt|||���q�W|j�||��|j�||���qWdS)$Ng��z�@y7Ă?�?g]�ֆ@znot complex��g@c@seZdZdd�Zdd�ZdS)z.CMathTests.test_user_object.<locals>.MyComplexcSs
||_dS)N)�value)r,rPrrr�__init__�sz7CMathTests.test_user_object.<locals>.MyComplex.__init__cSs|jS)N)rP)r,rrr�__complex__�sz:CMathTests.test_user_object.<locals>.MyComplex.__complex__N)�__name__�
__module__�__qualname__rQrRrrrr�	MyComplex�srVc@seZdZdd�Zdd�ZdS)z0CMathTests.test_user_object.<locals>.MyComplexOScSs
||_dS)N)rP)r,rPrrrrQ�sz9CMathTests.test_user_object.<locals>.MyComplexOS.__init__cSs|jS)N)rP)r,rrrrR�sz<CMathTests.test_user_object.<locals>.MyComplexOS.__complex__N)rSrTrUrQrRrrrr�MyComplexOS�srWc@seZdZdS)z2CMathTests.test_user_object.<locals>.SomeExceptionN)rSrTrUrrrr�
SomeException�srXcseZdZ�fdd�ZdS)z7CMathTests.test_user_object.<locals>.MyComplexExceptioncs��dS)Nr)r,)rXrrrR�szCCMathTests.test_user_object.<locals>.MyComplexException.__complex__N)rSrTrUrRr)rXrr�MyComplexException�srYcseZdZ�fdd�ZdS)z9CMathTests.test_user_object.<locals>.MyComplexExceptionOScs��dS)Nr)r,)rXrrrR�szECMathTests.test_user_object.<locals>.MyComplexExceptionOS.__complex__N)rSrTrUrRr)rXrr�MyComplexExceptionOS�srZc@seZdZdS)z;CMathTests.test_user_object.<locals>.NeitherComplexNorFloatN)rSrTrUrrrr�NeitherComplexNorFloat�sr[c@seZdZdS)z=CMathTests.test_user_object.<locals>.NeitherComplexNorFloatOSN)rSrTrUrrrr�NeitherComplexNorFloatOS�sr\c@seZdZdd�Zdd�ZdS)z*CMathTests.test_user_object.<locals>.MyIntcSsdS)N�r)r,rrr�__int__�sz2CMathTests.test_user_object.<locals>.MyInt.__int__cSsdS)Nr]r)r,rrr�	__index__�sz4CMathTests.test_user_object.<locals>.MyInt.__index__N)rSrTrUr^r_rrrr�MyInt�sr`c@seZdZdd�Zdd�ZdS)z,CMathTests.test_user_object.<locals>.MyIntOScSsdS)Nr]r)r,rrrr^�sz4CMathTests.test_user_object.<locals>.MyIntOS.__int__cSsdS)Nr]r)r,rrrr_�sz6CMathTests.test_user_object.<locals>.MyIntOS.__index__N)rSrTrUr^r_rrrr�MyIntOS�sracs$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_argrrrR�sz@CMathTests.test_user_object.<locals>.FloatAndComplex.__complex__N)rSrTrUrcrRr)rdrbrr�FloatAndComplex�srecs$eZdZ�fdd�Z�fdd�ZdS)z6CMathTests.test_user_object.<locals>.FloatAndComplexOScs�S)Nr)r,)rbrrrc�sz@CMathTests.test_user_object.<locals>.FloatAndComplexOS.__float__cs�S)Nr)r,)rdrrrR�szBCMathTests.test_user_object.<locals>.FloatAndComplexOS.__complex__N)rSrTrUrcrRr)rdrbrr�FloatAndComplexOS�srfcseZdZ�fdd�ZdS)z.CMathTests.test_user_object.<locals>.JustFloatcs�S)Nr)r,)rbrrrc�sz8CMathTests.test_user_object.<locals>.JustFloat.__float__N)rSrTrUrcr)rbrr�	JustFloat�srgcseZdZ�fdd�ZdS)z0CMathTests.test_user_object.<locals>.JustFloatOScs�S)Nr)r,)rbrrrc�sz:CMathTests.test_user_object.<locals>.JustFloatOS.__float__N)rSrTrUrcr)rbrr�JustFloatOS�srhy��z�@7Ă?�?g]�ֆ�)�object�NotImplemented�	Exception�test_functionsrJ�assertRaises�	TypeError)r,Z
non_complexesrVrWrYrZr[r\r`rarerfrgrh�fZbad_complexr)rXrdrbr�test_user_object�sB


zCMathTests.test_user_objectcCsfx4|jD]*}x$dD]}|j||�||j���qWqWx*|jD] }xd	D]}|jt||�qHWq>WdS)
Nr]�@r@�long_string�0�1j�)r]rq)r@rrrsrtru)rlrJrcrmrn)r,ro�argrrr�test_input_types
 
zCMathTests.test_input_typecCs6ddddddg}|dd�|D�d	d
dg}|d
gdd�|D�}d	g|}d	g|dd�|D�}|||||||||||||d
�
}x^|j�D]R\}}tt|�}	tt|�}
x4|D],}|
|�}|j|	|�|j�|jd	|j�q�Wq�WxJdD]B}
x<|D]4}tj||
�}|jtj||
�|j�|jd	|j�q�Wq�WdS)Ng{�G�z�?g�������?g�������?��?g�������?g�G�z��?cSsg|]
}|�qSrr)rrrrrr'sz6CMathTests.test_cmath_matches_math.<locals>.<listcomp>gg�?cSsg|]}d|�qS)g�?r)rrrrrr+scSsg|]
}|�qSrr)rrrrrr/s)
rrrrr r!r"r#r$r%r&r'r(�@�$@g�)rxryrz)	�itemsrr0rrCr7rJr8r")r,r+Z
unit_intervalZpositiveZnonnegativeZ	real_linerl�fn�valuesZfloat_fnZ
complex_fn�v�z�baserrr�test_cmath_matches_maths>





z"CMathTests.test_cmath_matches_mathc"Cs0dh}d}tjdkrNtj�d}yttt|jd���}Wntk
rLYnXdd�}dd�}�x�tt	�D�]�\}}}}	}
}}t
||	�}
t
|
|�}|dk	r�|dkr�||kr�qj|dkr�|}n|dkr�|}n
tt|�}d
|ks�d|k�r y||
�}Wntk
�rwjYnX|j
dj||||	��d|k�rfy||
�}Wntk
�rNwjYnX|j
dj||||	��||
�}d|k�r�t
t|j�|j�}t
t|j�|j�}d|k�r�t
|jt|j��}t
|jt|j��}|dk�r�d}nd}dj||||	|j|j|j|j�}|j|j|j||d�|j|j|j|d�qjWdS)NZtan0064�darwinr�.cSstj|j|j�S)zaWrapped version of rect that accepts a complex number instead of
            two float arguments.)rrr7r8)rrrr�rect_complex]sz5CMathTests.test_specific_values.<locals>.rect_complexcSstt|��S)zYWrapped version of polar that returns a complex number instead of
            two floats.)rr)rrrr�
polar_complexbsz6CMathTests.test_specific_values.<locals>.polar_complex�
rOrrzdivide-by-zeroZinvalidz9ValueError not raised in test {}: {}(complex({!r}, {!r}))Zoverflowz<OverflowError not raised in test {}: {}(complex({!r}, {!r}))zignore-real-signzignore-imag-signr"r#gV瞯�<g
z�{}: {}(complex({!r}, {!r}))
Expected: complex({!r}, {!r})
Received: complex({!r}, {!r})
Received value insufficiently close to expected value.)rBr5)r5)r�rO)r"r#)�sys�platformZmac_ver�tuple�map�int�split�
ValueErrorrrrrrr3r4r>r=r7r8rC)r,Z
SKIP_ON_TIGERZosx_versionZversion_txtr�r��idr|�arZaiZerZei�flagsrv�expectedZfunction�actualZreal_abs_errZ
error_messagerrr�test_specific_valuesOsl
 






zCMathTests.test_specific_valuescs���fdd�}|dd�|dd�|ddtf�|ddtdf�|dd
tdf�td�}|t|d�|df�|t|d�|tf�|td|�|tdf�|td
|�|tdf�|t||�|tdf�|t||�|tdf�|t||�|dtdf�|t||�|dtdf�td�}|t|d�||f�|td|�||f�|t||�||f�|t||�||f�|t||�||f�|t||�||f�|t||�||f�dS)Ncs0�|�}x"t||�D]\}}�j||�qWdS)N)�ziprC)rvr�ZgotrF�g)�funcr,rr�check�sz%CMathTests.check_polar.<locals>.checkr�rN��?y�?r]y@g@r
�rO�r)r�r�)r�r����y�����)r	�floatr)r,r�r�r
rr)r�r,r�check_polar�s.

 zCMathTests.check_polarcCs|jt�dS)N)r�r)r,rrr�
test_polar�szCMathTests.test_polarcs&ddlm��fdd�}|j|�dS)Nr)�	set_errnocs �d�zt|�S�d�XdS)N�r)r)r)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|jtd�d�|jtd�d�|jtd
�t�|jtd�t�|jtd�t�|jtd�td�|jtd�td�|jttdd��d�|jttdd��d�|jttdd��t�|jttdd��t�|jtttd��t�|jtttd��t�|jtttt��dt�|jttdt��td�|jttdt��td�|jttdt��td�|jttdt��td�|jtttt��td	�|jtttd��d�|jtttd��d�|jtttd��d�|jtttd��d�|jtttt��td	�|jttdt��td�|jttdt��td�|jttdt��td�|jttdt��td�|jtttt��dt�|jtttd��t�|jtttd��t�x"tD]}|jtj	t|����q�WdS) Nrgg�?yY��n�y�?r]gffffff@g�?r�g�g�y�Y��n�g�y�Y��n��y��g�g�g�g�g�g�gffffff�g�gffffff�g�gffffff�g�g�g�g�gffffff�)
rErr	rJr�INF�complex_nansrKr0r1)r,rrrr�
test_phase�sB
zCMathTests.test_phasecCs�xtD]}|jt|�d�qWxtD]}|jt|�t�q$W|jtttt��t�|jtj	tttd����|jtj	tttd����|jtj	tttd����|jtj	tttd����|jtttt��t�|jtttt��t�|jtj	ttdt����|jtj	ttdt����|jtj	ttdt����|jtj	ttdt����|jtttt��t�|jtj	tttt����dS)Nggffffff@gffffff�g�gffffff�g�)
�
complex_zerosrJr=�complex_infinitiesr�r�NANrKr0r1)r,rrrr�test_abs�s"

zCMathTests.test_abscCs|jtttdd��dS)Ng��U���)rmr>r=r)r,rrr�test_abs_overflowsszCMathTests.test_abs_overflowscCsBd}t|j|d�|ks0t|j|d�|kr>|j||f�dS)NgH�����z>rrN)r=r7r8r3)r,r@rAZepsrrr�assertCEquals,zCMathTests.assertCEqualcCsj|jtdd�d�|jtdd�d�|jtdt�d�|jtdtd�d	�|jtdtd�d�dS)NrrN��?r])rr)r�r��)r�r)rr���)rr�)r�rr	)r,rrr�	test_rects
zCMathTests.test_rectcCsjtd�ddddtd�td�g}xF|D]>}x8|D]0}t||�}|jtj|�tj|�oZtj|��q.Wq$WdS)Nz-infgffffff@gr
rgffffff�g�)r�rrJrZisfiniter0)r,Z	real_valsrrrrrr�
test_isfinite$s



zCMathTests.test_isfinitecCs�|jtjd��|jtjd��|jtjt��|jtjt��|jtjttd���|jtjtdt���|jtjttt���|jtjttt���|jtjttt���dS)NrNy�?r)�assertFalserr1r�rKr�r)r,rrr�
test_isnan-szCMathTests.test_isnancCs�|jtjd��|jtjd��|jtjt��|jtjt��|jtjttd���|jtjtdt���|jtjttt���|jtjttt���|jtjttt���dS)NrNy�?r)r�rr<r�rKr�r)r,rrr�
test_isinf8szCMathTests.test_isinf�TANH_PRESERVES_ZERO_SIGNrz,system tanh() function doesn't copy the signcCs$xtD]}|jtj|�|�qWdS)N)r�r9rr()r,rrrr�testTanhSignCs
zCMathTests.testTanhSigncCs$xtD]}|jtj|�|�qWdS)N)r�r9rr)r,rrrr�testAtanSignNs
zCMathTests.testAtanSigncCs$xtD]}|jtj|�|�qWdS)N)r�r9rr)r,rrrr�
testAtanhSignSs
zCMathTests.testAtanhSign)rrrrrrrr r!r"r#r$r%r&r'r()r:r;N)$rSrTrUrl�appendr-r/r6r9rCrGrMrprwr�rr�r�r�rr�r�r�r�r�r�r�r�r��unittestZskipIf�	sysconfig�get_config_varr�r�r�rrrrr4sD

1c0W)		rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�IsCloseTestscCsx|jt��|jdddd�WdQRX|jt��|jdddd�WdQRX|jt��|jddddd�WdQRXdS)Ny�?)�rel_tol)�abs_tol)r�r�)rmrn�isclose)r,rrr�test_reject_complex_tolerances\sz+IsCloseTests.test_reject_complex_tolerancescCs,ddddg}|j|dd�|j|dd�dS)Ng�?y�?g��?y��?y������?g�-���q=)r�g�vIh�%<=��?�?���?�?)r�r���?�?��?��?)r�r�g���?g����?)r�r���?��?������)r�r�)�assertAllClose�assertAllNotClose)r,Zcomplex_examplesrrr�test_complex_valuesfsz IsCloseTests.test_complex_valuescCsPdd	ddddg}|j|dd�|j|dd�|jdddd�|jdddd�dS)N�����MbP?r���MbP?g�~j�t�X?)r�g����Mb@?g����Mb`?)r�r)r�r�����MbP?����MbP?)r�rg����MbP������MbP�����MbP?)r�r�����MbP?����MbP�)r�rg����MbP������MbP�����MbP�)r�ry����MbP?����MbP�y����MbP?����MbP?y����MbP?����MbP�y����MbP?����MbP?)r�r�Z
assertIsCloseZassertIsNotClose)r,Znear_zero_examplesrrr�test_complex_near_zeroqsz#IsCloseTests.test_complex_near_zeroN)rSrTrUrr�r�r�r�rrrrr�Ys
r��__main__��)rr�g�gffffff�g�gffffff�gffffff�g�gffffff�g�gffffff�g�gffffff�g�)Ztest.supportrrZtest.test_mathrrZ	test_mathr�rr0rrrr	r�r�r�r�r�r�r�r�r�ZTestCaserr�rS�mainrrrr�<module>sj

))