
    ;e`                     @   d dl mZmZmZ d dlmZmZ d dlmZ d dlZd dl	Z	d dl
Z
d dl	mZmZmZmZ d dlZd dlZ ed          Z ed          Zd dD             Zd	 ed
fedfeefdefd
efdefdefe efe dfe d
fe dfe dfe e fde fde fd
e fde fee fedfedffD             Zd ee fedfedfed
fedfeefe efdefdefd
efdefeeffD             Z G d dej                  Z G d dej                  Zedk    r ej                     dS dS )    )requires_IEEE_754cpython_onlyimport_helper)parse_testfile	test_fileN)phasepolarrectpiinfnanc                 8    g | ]}d D ]}t          ||          S )               complex.0xys      &/usr/lib/python3.11/test/test_cmath.py
<listcomp>r      s-    III1[IIAIIII    r   c                 4    g | ]\  }}t          ||          S  r   r   s      r   r   r      s0       1gamm   r   r   ffffff@r   ffffffc                 4    g | ]\  }}t          ||          S r   r   r   s      r   r   r   %   s0       $!Q1   r   c                   z   e Zd Zd dD             Ze                    d            e                    d            d Zd Zd Zd Z	 	 d!dZ	d Z
d Zd Zd Zd Zed             Zd Zd Zed             Zd Zd Zed             Zd Zd Zd Zd Zd Zed             Zed             Zed              ZdS )"
CMathTestsc                 8    g | ]}t          t          |          S r   )getattrcmath)r   fnames     r   r   zCMathTests.<listcomp>6   s.     $ $ $geU++ $ $ $r   )acosacoshasinasinhatanatanhcoscoshexploglog10sinsinhsqrttantanhc                 ,    t          j        | d          S )Ny     @        r$   r/   r   s    r   <lambda>zCMathTests.<lambda>;   s    UYq*%=%= r   c                 ,    t          j        d|           S )Ny      ,@      ;r7   r8   s    r   r9   zCMathTests.<lambda><   s    UYw%:%: r   c                 <    t          t          d          | _        d S )Nzutf-8)encoding)openr   test_valuesselfs    r   setUpzCMathTests.setUp>   s    	G<<<r   c                 8    | j                                          d S N)r>   closer?   s    r   tearDownzCMathTests.tearDownA   s         r   c                    d}t          j        |          st          j        |          r+t          j        |          rt          j        |          rdS nA||k    r;|dk    rdS t          j        d|          t          j        d|          k    rdS |dz  }|                     |                    ||                     dS )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)r@   r   r   msgs       r   assertFloatIdenticalzCMathTests.assertFloatIdenticalD   s     7:a== 
	6DJqMM 
	6z!}} A !VVCxxsA&&$-Q*?*???55		#**Q""#####r   c                     |                      |j        |j                   |                      |j        |j                   dS )zFail 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)rN   realimag)r@   r   r   s      r   assertComplexIdenticalz!CMathTests.assertComplexIdentical[   s>     	!!!&!&111!!!&!&11111r   V瞯<
       Nc                    t          j        |          r@t          j        |          rdS |                     |pd                    |                     t          j        |          r3||k    rdS |                     |pd                    ||                     |sY|sWt          j        d|          t          j        d|          k    r+|                     |pd                    ||                     	 t          ||z
            }|t          ||t          |          z            k    rdS n# t          $ r Y nw xY w|                     |pd                    ||                     dS )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}rG   z,zero has wrong sign: expected {!r}, got {!r}z({!r} and {!r} are not sufficiently close)	rH   rI   rK   rL   isinfrJ   absmaxOverflowError)r@   abrel_errabs_errrM   absolute_errors          r   rAssertAlmostEqualzCMathTests.rAssertAlmostEquale   s    :a== 	=z!}} IIc;188;;<<<:a== 	>AvvIIc = 006q!> > >  	3 	3}R##t}R';';;;		# 2 "%%+VAq\\3 3 3
	 1XXN WgA.>!?!??? @  	 	 	D	 			# J<CCAqII	K 	K 	K 	K 	Ks   8D1 1
D>=D>c           	         d}d}|                      t          j        |dd                    t          j        |                     |                      t          j        |dd                    t          j        |                     d S )NgiW
@g-DT!	@	   zcmath.pi is {}; should be {})placesrM   zcmath.e is {}; should be {})assertAlmostEqualr$   r   rL   e)r@   
e_expectedpi_expecteds      r   test_constantszCMathTests.test_constants   s    +
,uxQ.55ehLL 	 	N 	N 	Nuw
1-44UWjII 	 	K 	K 	K 	K 	Kr   c                 *   |                      t          j        j        t          j                   |                      t          j        j        d           |                      t          j        j        d           |                      t          j        j        t          j                   |                     t	          j        t          j	        j                             |                      t          j	        j        d           |                      t          j
        j        d           |                     t	          j        t          j
        j                             |                      t          t          j                  d           |                      t          t          j                  d           |                      t          t          j	                  d           |                      t          t          j
                  d           d S )Nr   r   infjr   nanj)assertEqualr$   r   rP   rH   rQ   ri   
assertTruerI   r   rj   reprr?   s    r   test_infinity_and_nan_constantsz*CMathTests.test_infinity_and_nan_constants   sf   222---#...$(333
59>22333---#...
5:?33444 	ei%000ej))6222ei%000ej))622222r   c           
         ddddddd t                      t          g} G d dt                     } G d	 d
          } G d dt                     G fddt                     } G fdd          } G d dt                     } G d d          } G d d          } G d d          }	 G fddt                     }
 G fdd          } G fddt                     } G fdd           }| j        D ]c}|                      | |                     |                     |                      | |                     |                     |                      | |
                       |                     |                      | |                       |                     |                      | |                       |                     |                      | |                       |                     |                      | |                       |t           |                                           |                     t          | |                       |                     t          | |	                       |                     t          | |                       |D ]L}|                     t          | ||                     |                     t          | ||                     M|                     | |                       |                     | |                       ed S )!Nyz@7Ă??g]ֆznot complex             @c                       e Zd Zd Zd ZdS ).CMathTests.test_user_object.<locals>.MyComplexc                     || _         d S rC   valuer@   rw   s     r   __init__z7CMathTests.test_user_object.<locals>.MyComplex.__init__       "


r   c                     | j         S rC   rv   r?   s    r   __complex__z:CMathTests.test_user_object.<locals>.MyComplex.__complex__   
    z!r   N__name__
__module____qualname__ry   r|   r   r   r   	MyComplexrt      2        # # #" " " " "r   r   c                       e Zd Zd Zd ZdS )0CMathTests.test_user_object.<locals>.MyComplexOSc                     || _         d S rC   rv   rx   s     r   ry   z9CMathTests.test_user_object.<locals>.MyComplexOS.__init__   rz   r   c                     | j         S rC   rv   r?   s    r   r|   z<CMathTests.test_user_object.<locals>.MyComplexOS.__complex__   r}   r   Nr~   r   r   r   MyComplexOSr      r   r   r   c                       e Zd ZdS )2CMathTests.test_user_object.<locals>.SomeExceptionNr   r   r   r   r   r   SomeExceptionr              Dr   r   c                       e Zd Z fdZdS )7CMathTests.test_user_object.<locals>.MyComplexExceptionc                     rC   r   r@   r   s    r   r|   zCCMathTests.test_user_object.<locals>.MyComplexException.__complex__   	    ##r   Nr   r   r   r|   r   s   r   MyComplexExceptionr      .        $ $ $ $ $ $ $r   r   c                       e Zd Z fdZdS )9CMathTests.test_user_object.<locals>.MyComplexExceptionOSc                     rC   r   r   s    r   r|   zECMathTests.test_user_object.<locals>.MyComplexExceptionOS.__complex__   r   r   Nr   r   s   r   MyComplexExceptionOSr      r   r   r   c                       e Zd ZdS );CMathTests.test_user_object.<locals>.NeitherComplexNorFloatNr   r   r   r   NeitherComplexNorFloatr      r   r   r   c                       e Zd ZdS )=CMathTests.test_user_object.<locals>.NeitherComplexNorFloatOSNr   r   r   r   NeitherComplexNorFloatOSr      r   r   r   c                       e Zd Zd Zd ZdS )*CMathTests.test_user_object.<locals>.Indexc                     dS N   r   r?   s    r   __int__z2CMathTests.test_user_object.<locals>.Index.__int__       aar   c                     dS r   r   r?   s    r   	__index__z4CMathTests.test_user_object.<locals>.Index.__index__   s    r   N)r   r   r   r   r   r   r   r   Indexr      s"        ''')))))r   r   c                       e Zd Zd ZdS )*CMathTests.test_user_object.<locals>.MyIntc                     dS r   r   r?   s    r   r   z2CMathTests.test_user_object.<locals>.MyInt.__int__   r   r   N)r   r   r   r   r   r   r   MyIntr      s        '''''r   r   c                   $    e Zd ZfdZ fdZdS )4CMathTests.test_user_object.<locals>.FloatAndComplexc                     S rC   r   r@   flt_args    r   	__float__z>CMathTests.test_user_object.<locals>.FloatAndComplex.__float__       r   c                     S rC   r   r@   cx_args    r   r|   z@CMathTests.test_user_object.<locals>.FloatAndComplex.__complex__       r   Nr   r   r   r   r|   r   r   s   r   FloatAndComplexr      G                  r   r   c                   $    e Zd ZfdZ fdZdS )6CMathTests.test_user_object.<locals>.FloatAndComplexOSc                     S rC   r   r   s    r   r   z@CMathTests.test_user_object.<locals>.FloatAndComplexOS.__float__   r   r   c                     S rC   r   r   s    r   r|   zBCMathTests.test_user_object.<locals>.FloatAndComplexOS.__complex__   r   r   Nr   r   s   r   FloatAndComplexOSr      r   r   r   c                       e Zd Z fdZdS ).CMathTests.test_user_object.<locals>.JustFloatc                     S rC   r   r   s    r   r   z8CMathTests.test_user_object.<locals>.JustFloat.__float__   r   r   Nr   r   r   r   r   s   r   	JustFloatr      .              r   r   c                       e Zd Z fdZdS )0CMathTests.test_user_object.<locals>.JustFloatOSc                     S rC   r   r   s    r   r   z:CMathTests.test_user_object.<locals>.JustFloatOS.__float__   r   r   Nr   r   s   r   JustFloatOSr      r   r   r   )objectNotImplemented	Exceptiontest_functionsrk   intassertRaises	TypeError)r@   non_complexesr   r   r   r   r   r   r   r   r   r   r   r   fbad_complexr   r   r   s                   @@@r   test_user_objectzCMathTests.test_user_object   s    , '1b$>3	" 	" 	" 	" 	" 	" 	" 	"	" 	" 	" 	" 	" 	" 	" 	"	 	 	 	 	I 	 	 		$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$
	 	 	 	 	V 	 	 		 	 	 	 	 	 	 		* 	* 	* 	* 	* 	* 	* 	*	( 	( 	( 	( 	( 	( 	( 	(
	 	 	 	 	 	 	 	f 	 	 	
	 	 	 	 	 	 	 	 	 	 	
	 	 	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	 $ 	H 	HAQQyy001111V99===QQ{{62233QQvYY???QQ001111V99===QQ002233QQvYY???QQyy{{^^QQwZZ888QQ{{}}--qqzz:::QQuuwwZZ3uuww<<999 i,B,B,D,DEEEiEEGG444i,D,D,F,FGGG, J J!!)Q		+0F0FGGG!!)QK0H0HIIIImQ0B0B0D0DEEEmQ0D0D0F0FGGGG1	H 	Hr   c           	          | j         D ]A}dD ]<}|                      ||           ||                                                     =B| j         D ]#}dD ]}|                     t          ||           $d S )N)r   rr   )rZ   long_string01j )r   rk   r   r   r   )r@   r   args      r   test_input_typezCMathTests.test_input_type  s     $ 	= 	=A = =  33==??););<<<<= $ 	5 	5A: 5 5!!)Q44445	5 	5r   c                    g d}|d |D             z   g dz   }|dgz   d |D             z   }dg|z   }dg|z   d |D             z   }|||||||||||||d}|                                 D ]~\  }}t          t          |          }	t          t          |          }
|D ]L} |
|          }|                      |	|          |j                   |                     d|j                   Md	D ]e}|D ]`}t          j        ||          }|                     t          j        ||          |j                   |                     d|j                   afd S )
N)g{Gz?g?g?      ?g?gGz?c                     g | ]}| S r   r   r   r   s     r   r   z6CMathTests.test_cmath_matches_math.<locals>.<listcomp>&  s    &?&?&?ar&?&?&?r   )r   rG         rG   c                     g | ]}d |z  S )rG   r   r   s     r   r   z6CMathTests.test_cmath_matches_math.<locals>.<listcomp>*  s    (C(C(C!A(C(C(Cr   r   c                     g | ]}| S r   r   r   s     r   r   z6CMathTests.test_cmath_matches_math.<locals>.<listcomp>.  s    &<&<&<ar&<&<&<r   )r&   r(   r*   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   )r   rr   g      $@)	itemsr#   rH   r$   r_   rP   rk   rQ   r/   )r@   r>   unit_intervalpositivenonnegative	real_liner   fnvaluesfloat_fn
complex_fnvzbases                 r   test_cmath_matches_mathz"CMathTests.test_cmath_matches_math  s   
 766 $&?&?;&?&?&??MM "%(C(C{(C(C(CCdXo D8O&<&<8&<&<&<<	 #"     )..00 	- 	-JBtR((H ++J - -JqMM''QV<<<  QV,,,,- # 	- 	-D - -Ia&&''D(9(916BBB  QV,,,,-	- 	-r   c                 x   dh}d }t           j        dk    r`t          j                    d         }	 t          t	          t
          |                    d                              }n# t          $ r Y nw xY wd }d }t          t                    D ](\  }}}}	}
}}t          ||	          }t          |
|          }||dk     r||v r8|dk    r|}n|d	k    r|}nt          t          |          }d
|v sd|v rH	  ||          }|                     d                    ||||	                     n# t          $ r Y w xY wd|v rH	  ||          }|                     d                    ||||	                     n# t          $ r Y w xY w ||          }d|v rNt          t!          |j                  |j                  }t          t!          |j                  |j                  }d|v rNt          |j        t!          |j                            }t          |j        t!          |j                            }|dv rd}nd}d                    ||||	|j        |j        |j        |j                  }|                     |j        |j        ||           |                     |j        |j        |           *d S )Ntan0064darwinr   .c                 @    t          j        | j        | j                  S )zaWrapped version of rect that accepts a complex number instead of
            two float arguments.)r$   r
   rP   rQ   r   s    r   rect_complexz5CMathTests.test_specific_values.<locals>.rect_complex\  s     :afaf---r   c                 .    t          t          |            S )zYWrapped version of polar that returns a complex number instead of
            two floats.)r   r	   r   s    r   polar_complexz6CMathTests.test_specific_values.<locals>.polar_complexa  s     E!HH%%r   )
   rq   r
   r	   zdivide-by-zeroinvalidz9ValueError not raised in test {}: {}(complex({!r}, {!r}))overflowz<OverflowError not raised in test {}: {}(complex({!r}, {!r}))zignore-real-signzignore-imag-sign)r/   r0   rS   rT   z{}: {}(complex({!r}, {!r}))
Expected: complex({!r}, {!r})
Received: complex({!r}, {!r})
Received value insufficiently close to expected value.)r]   rM   )rM   )sysplatformmac_vertuplemapr   split
ValueErrorr   r   r   r#   r$   rK   rL   rY   rW   rP   rQ   r_   )r@   SKIP_ON_TIGERosx_versionversion_txtr   r   idr   araiereiflagsr   expectedfunctionactualreal_abs_errerror_messages                      r   test_specific_valueszCMathTests.test_specific_valuesN  sq    #<8##"*,,Q/K#C[->->s-C-C$D$DEE   	. 	. 	.
	& 	& 	&
 .<I-F-F =	; =	;)BBBE"b//Cr2H &;+@+@&&V||'w("5"--5((I,>,>P%Xc]]F II 88>r2r28N8NP P P P "   H U""P%Xc]]F II 88>r2r28N8NP P P P %   H Xc]]F!U** V[!1!16;??"3x}#5#5x}EE!U** c&+.>.>??"8=#hm2D2DEE %%%$%I &RR]HM[&+/ /  ##HM6;0<,9 $ ; ; ; ##HM6;,9 $ ; ; ; ;y=	; =	;s5   5A& &
A32A38D//
D<;D<E;;
FFc                      fd} |dd            |dd            |ddt           f            |ddt           d	z  f            |d
dt            d	z  f           t          d          } |t          |d          |df            |t          | d          |t           f            |t          d|          |t           d	z  f            |t          d|           |t            d	z  f            |t          ||          |t           dz  f            |t          ||           |t            dz  f            |t          | |          |dt           z  dz  f            |t          | |           |dt           z  dz  f           t          d          } |t          |d          ||f            |t          d|          ||f            |t          ||          ||f            |t          ||          ||f            |t          | |          ||f            |t          ||          ||f            |t          ||           ||f           d S )Nc                 v     |           }t          ||          D ]\  }}                    ||           d S rC   )zipr_   )r   r  gotrd   gfuncr@   s        r   checkz%CMathTests.check_polar.<locals>.check  sP    $s))CHc** . .1''1----. .r   r   )r   r   rp   )rG   r   rG                 ?r   y             g      @r   r      rq      r   )r   floatr   )r@   r  r  r   r   s   ``   r   check_polarzCMathTests.check_polar  s   	. 	. 	. 	. 	. 	. 	aab2r(b2rAv,cBa=!!!Ellgc1ooRy)))gsdAb	***gaooR!V}---ga#rcAg///gc3#rAv///gcC4  3a.111gsdC  3B
"3444gsdSD!!Cb1#5666Ellgc1ooSz***gaooSz***gc3#s,,,gc3#s,,,gsdC  3*---gc3#s,,,gcC4  3*-----r   c                 :    |                      t                     d S rC   )r#  r	   r?   s    r   
test_polarzCMathTests.test_polar  s    r   c                 d    t          j        d          fd}|                     |           d S )N	_testcapic                                          d           	 t          |                                d           S #                      d           w xY w)N   r   )	set_errnor	   )r   r'  s    r   polar_with_errno_setz9CMathTests.test_polar_errno.<locals>.polar_with_errno_set  sV    ###'Qxx##A&&&&	##A&&&&s	   < A)r   import_moduler#  )r@   r+  r'  s     @r   test_polar_errnozCMathTests.test_polar_errno  sK     "/<<		' 	' 	' 	' 	' 	-.....r   c                    |                      t          d          d           |                      t          d          d           |                      t          d          t                     |                      t          d          t                     |                      t          d          t                      |                      t          d          t          dz             |                      t          d	          t           dz             |                     t          t	          dd                    d           |                     t          t	          dd
                    d
           |                     t          t	          d
d                    t                     |                     t          t	          d
d
                    t                      |                      t          t	          t
           d
                    t                      |                      t          t	          t
           d                    t                      |                      t          t	          t
           t
                               dt          z             |                      t          t	          dt
                               t           dz             |                      t          t	          d
t
                               t           dz             |                      t          t	          dt
                               t           dz             |                      t          t	          dt
                               t           dz             |                      t          t	          t
          t
                               t           dz             |                     t          t	          t
          d                    d
           |                     t          t	          t
          d
                    d
           |                     t          t	          t
          d                    d           |                     t          t	          t
          d                    d           |                      t          t	          t
          t
                              t          dz             |                      t          t	          dt
                              t          dz             |                      t          t	          dt
                              t          dz             |                      t          t	          d
t
                              t          dz             |                      t          t	          dt
                              t          dz             |                      t          t	          t
           t
                              dt          z             |                      t          t	          t
           d                    t                     |                      t          t	          t
           d                    t                     t          D ]6}|                     t          j	        t          |                               7d S )Nr   r   rG   r   y      Yny      Ynr  r   y             r   r   g      r   r   g      ?)
rc   r   r   rk   r   INFcomplex_nansrl   rH   rI   r@   r   s     r   
test_phasezCMathTests.test_phase  s2   uQxx,,,uRyy"---uSzz2...u[112666u[11B3777uRyy"Q$///uSzzB3q5111 	wsC00113777wsD1122D999wtS1122B777wtT2233bS999 	uWcT4%8%899B3???uWcT4%8%899B3???uWcTC4%8%89958DDDuWTC4%8%899B3q5AAAuWTC4%8%899B3q5AAAuWS3$%7%7882#a%@@@uWS3$%7%7882#a%@@@uWS3$%7%7882#a%@@@wsD1122D999wsD1122D999wsC00113777wsC00113777uWS#%6%677A>>>uWS#%6%677A>>>uWS#%6%677A>>>uWT3%7%788"Q$???uWT3%7%788"Q$???uWcT3%7%788$r'BBBuWcT3%7%788"===uWcT3%7%788"===  	2 	2AOODJuQxx001111	2 	2r   c           
         t           D ]%}|                     t          |          d           &t          D ]*}|                     t          |          t                     +|                     t          t          t          t                               t                     |                     t          j	        t          t          t          d                                         |                     t          j	        t          t          t          d                                         |                     t          j	        t          t          t          d                                         |                     t          j	        t          t          t          d                                         |                     t          t          t          t                              t                     |                     t          t          t           t                              t                     |                     t          j	        t          t          dt                                                   |                     t          j	        t          t          dt                                                   |                     t          j	        t          t          dt                                                   |                     t          j	        t          t          dt                                                   |                     t          t          t          t                              t                     |                     t          j	        t          t          t          t                                                   d S )Nr   r   r   r   )
complex_zerosrk   rW   complex_infinitiesr/  r   NANrl   rH   rI   r1  s     r   test_abszCMathTests.test_abs  s    	* 	*ASVVS)))) $ 	* 	*ASVVS)))) 	WS3$//00#666
3wsD'9'9#:#:;;<<<
3wsD'9'9#:#:;;<<<
3wsC'8'8#9#9::;;;
3wsC'8'8#9#9::;;;WS#..//555WcT3//00#666
3wtS'9'9#:#:;;<<<
3wtS'9'9#:#:;;<<<
3wsC'8'8#9#9::;;;
3wsC'8'8#9#9::;;;WS#..//555
3wsC'8'8#9#9::;;;;;r   c                 d    |                      t          t          t          dd                     d S )NgU)r   rY   rW   r   r?   s    r   test_abs_overflowszCMathTests.test_abs_overflows  s,     	-ggw.G.GHHHHHr   c                     d}t          |j        |d         z
            |k    s!t          |j        |d         z
            |k    r|                     ||f           d S d S )NgHz>r   rp   )rW   rP   rQ   rK   )r@   rZ   r[   epss       r   assertCEqualzCMathTests.assertCEqual  se    qv!}##s16AaD='9'9C'?'?IIq!f (@'?r   c                    |                      t          dd          d           |                      t          dd          d           |                      t          dt                     d           |                      t          dt          dz            d           |                      t          dt           dz            d           d S )	Nr   )r   r   rp   )rG   r   )r   r   r   )r   rG   )r   r   )r<  r
   r   r?   s    r   	test_rectzCMathTests.test_rect  s    $q!**f---$q!**g...$q2#,,111$q"Q$--111$q2#a%..(33333r   c           	      6   t          d          ddddt          d          t          d          g}|D ]e}|D ]`}t          ||          }|                     t          j        |          t          j        |          ot          j        |                     afd S )Nz-infr   r   r   r   r   r   )r"  r   rk   r$   isfiniterH   )r@   	real_valsr   r   r   s        r   test_isfinitezCMathTests.test_isfinite#  s    6]]D$#uU||U5\\;	 	I 	IA I IAqMM  !2!2"&-"2"2"Gt}Q7G7GI I I II	I 	Ir   c                    |                      t          j        d                     |                      t          j        d                     |                      t          j        t                               |                     t          j        t
                               |                     t          j        t          t
          d                               |                     t          j        t          dt
                                         |                     t          j        t          t
          t
                                         |                     t          j        t          t
          t                                         |                     t          j        t          t          t
                                         d S Nrp   r  r   )assertFalser$   rI   r/  rl   r6  r   r?   s    r   
test_isnanzCMathTests.test_isnan,  4   Q(((R)))S))***C(()))GCOO44555GAsOO44555GC$5$566777GC$5$566777GC$5$56677777r   c                    |                      t          j        d                     |                      t          j        d                     |                      t          j        t                               |                     t          j        t
                               |                     t          j        t          t
          d                               |                     t          j        t          dt
                                         |                     t          j        t          t
          t
                                         |                     t          j        t          t          t
                                         |                     t          j        t          t
          t                                         d S rD  )rE  r$   rV   r6  rl   r/  r   r?   s    r   
test_isinfzCMathTests.test_isinf7  rG  r   c                 j    t           D ]*}|                     t          j        |          |           +d S rC   )r4  rR   r$   r5   r1  s     r   testTanhSignzCMathTests.testTanhSignB  <     	: 	:A''
1q9999	: 	:r   c                 j    t           D ]*}|                     t          j        |          |           +d S rC   )r4  rR   r$   r*   r1  s     r   testAtanSignzCMathTests.testAtanSignK  rL  r   c                 j    t           D ]*}|                     t          j        |          |           +d S rC   )r4  rR   r$   r+   r1  s     r   testAtanhSignzCMathTests.testAtanhSignP  s<     	; 	;A''A::::	; 	;r   )rS   rT   N) r   r   r   r   appendrA   rE   rN   rR   r_   rg   rn   r   r   r   r   r  r#  r%  r   r-  r2  r7  r9  r<  r>  rB  rF  rI  rK  rN  rP  r   r   r   r!   r!   4   sT       $ $ :# $ $ $N
 ==>>>::;;;= = =! ! !$ $ $.2 2 2 CI#0K 0K 0K 0KdK K K3 3 3"`H `H `HD
5 
5 
5.- .- .-` T; T; T;l. . .8      	/ 	/ \	/'2 '2 '2R< < <2 I I I  
4 4 4I I I	8 	8 	8	8 	8 	8 : : : : : : ; ; ; ; ;r   r!   c                   .    e Zd Zej        Zd Zd Zd ZdS )IsCloseTestsc                    |                      t                    5  |                     ddd           d d d            n# 1 swxY w Y   |                      t                    5  |                     ddd           d d d            n# 1 swxY w Y   |                      t                    5  |                     dddd           d d d            d S # 1 swxY w Y   d S )Nr  rel_tolabs_tol)rV  rX  )r   r   iscloser?   s    r   test_reject_complex_tolerancesz+IsCloseTests.test_reject_complex_tolerancesY  s   y)) 	- 	-LLRL,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- y)) 	- 	-LLRL,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- y)) 	9 	9LLRRL888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s5   A  AA%B

BB/CCCc                 j    g d}|                      |d           |                     |d           d S )N))      ?      ?y    ?      ?)r\  y      ?    ?)y            ?y          ?)y      ?      y      ?g-q=rU  gvIh%<=)assertAllCloseassertAllNotClose)r@   complex_exampless     r   test_complex_valuesz IsCloseTests.test_complex_valuesc  sP       	,e<<</?????r   c                     g d}|                      |d           |                     |d           |                     ddd           |                     ddd           d S )	N))y        MbP?r   )MbP?r   )MbP?MbP?r   )yMbPMbP?r   )MbP?MbPr   )yMbPMbPr   g~jtX?rW  gMb@?rd  rc  gMb`?rb  )r]  r^  assertIsCloseassertIsNotClose)r@   near_zero_exampless     r   test_complex_near_zeroz#IsCloseTests.test_complex_near_zeron  s          	.@@@17CCC<uEEElL%HHHHHr   N)r   r   r   r$   rY  rZ  r`  rh  r   r   r   rS  rS  V  sP        mG9 9 9	@ 	@ 	@I I I I Ir   rS  __main__)test.supportr   r   r   test.test_mathr   r   	test_mathunittestr$   rH   r   r	   r
   r   r  r   r"  r/  r6  r4  r5  r0  TestCaser!   rS  r   mainr   r   r   <module>rp     s   G G G G G G G G G G 4 4 4 4 4 4 4 4 " " " " " "          ( ( ( ( ( ( ( ( ( ( ( (  



 eElleEllIIIII 	c
	c
	c
	c
	c
	s	s
s
s
s
t
t
t	t	t	sd	sd	sd	d	d)1
    , 	sd	d	d	c
	c
	c

s	s	s	c
	c
	c
+
   _; _; _; _; _;" _; _; _;D&I &I &I &I &I9) &I &I &IR zHMOOOOO r   