<s> from test . support import run_unittest , requires_IEEE_754 <EOL> from test . test_math import parse_testfile , test_file <EOL> import unittest <EOL> import cmath , math <EOL> from cmath import phase , polar , rect , pi <EOL> import sysconfig <EOL> INF = float ( '<STR_LIT>' ) <EOL> NAN = float ( '<STR_LIT>' ) <EOL> complex_zeros = [ complex ( x , y ) for x in [ <NUM_LIT:0.0> , - <NUM_LIT:0.0> ] for y in [ <NUM_LIT:0.0> , - <NUM_LIT:0.0> ] ] <EOL> complex_infinities = [ complex ( x , y ) for x , y in [ <EOL> ( INF , <NUM_LIT:0.0> ) , <EOL> ( INF , <NUM_LIT> ) , <EOL> ( INF , INF ) , <EOL> ( <NUM_LIT> , INF ) , <EOL> ( <NUM_LIT:0.0> , INF ) , <EOL> ( - <NUM_LIT:0.0> , INF ) , <EOL> ( - <NUM_LIT> , INF ) , <EOL> ( - INF , INF ) , <EOL> ( - INF , <NUM_LIT> ) , <EOL> ( - INF , <NUM_LIT:0.0> ) , <EOL> ( - INF , - <NUM_LIT:0.0> ) , <EOL> ( - INF , - <NUM_LIT> ) , <EOL> ( - INF , - INF ) , <EOL> ( - <NUM_LIT> , - INF ) , <EOL> ( - <NUM_LIT:0.0> , - INF ) , <EOL> ( <NUM_LIT:0.0> , - INF ) , <EOL> ( <NUM_LIT> , - INF ) , <EOL> ( INF , - INF ) , <EOL> ( INF , - <NUM_LIT> ) , <EOL> ( INF , - <NUM_LIT:0.0> ) <EOL> ] ] <EOL> complex_nans = [ complex ( x , y ) for x , y in [ <EOL> ( NAN , - INF ) , <EOL> ( NAN , - <NUM_LIT> ) , <EOL> ( NAN , - <NUM_LIT:0.0> ) , <EOL> ( NAN , <NUM_LIT:0.0> ) , <EOL> ( NAN , <NUM_LIT> ) , <EOL> ( NAN , INF ) , <EOL> ( - INF , NAN ) , <EOL> ( - <NUM_LIT> , NAN ) , <EOL> ( - <NUM_LIT:0.0> , NAN ) , <EOL> ( <NUM_LIT:0.0> , NAN ) , <EOL> ( <NUM_LIT> , NAN ) , <EOL> ( INF , NAN ) <EOL> ] ] <EOL> class CMathTests ( unittest . TestCase ) : <EOL> test_functions = [ getattr ( cmath , fname ) for fname in [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ] <EOL> test_functions . append ( lambda x : cmath . log ( x , <NUM_LIT> + <NUM_LIT> ) ) <EOL> test_functions . append ( lambda x : cmath . log ( <NUM_LIT> - <NUM_LIT> , x ) ) <EOL> def setUp ( self ) : <EOL> self . test_values = open ( test_file ) <EOL> def tearDown ( self ) : <EOL> self . test_values . close ( ) <EOL> def assertFloatIdentical ( self , x , y ) : <EOL> """<STR_LIT>""" <EOL> msg = '<STR_LIT>' <EOL> if math . isnan ( x ) or math . isnan ( y ) : <EOL> if math . isnan ( x ) and math . isnan ( y ) : <EOL> return <EOL> elif x == y : <EOL> if x != <NUM_LIT:0.0> : <EOL> return <EOL> elif math . copysign ( <NUM_LIT:1.0> , x ) == math . copysign ( <NUM_LIT:1.0> , y ) : <EOL> return <EOL> else : <EOL> msg += '<STR_LIT>' <EOL> self . fail ( msg . format ( x , y ) ) <EOL> def assertComplexIdentical ( self , x , y ) : <EOL> """<STR_LIT>""" <EOL> self . assertFloatIdentical ( x . real , y . real ) <EOL> self . assertFloatIdentical ( x . imag , y . imag ) <EOL> def rAssertAlmostEqual ( self , a , b , rel_err = <NUM_LIT> , abs_err = <NUM_LIT> , <EOL> msg = None ) : <EOL> """<STR_LIT>""" <EOL> if math . isnan ( a ) : <EOL> if math . isnan ( b ) : <EOL> return <EOL> self . fail ( msg or '<STR_LIT>' . format ( b ) ) <EOL> if math . isinf ( a ) : <EOL> if a == b : <EOL> return <EOL> self . fail ( msg or '<STR_LIT>' <EOL> '<STR_LIT>' . format ( a , b ) ) <EOL> if not a and not b : <EOL> if math . copysign ( <NUM_LIT:1.> , a ) != math . copysign ( <NUM_LIT:1.> , b ) : <EOL> self . fail ( msg or '<STR_LIT>' <EOL> '<STR_LIT>' . format ( a , b ) ) <EOL> try : <EOL> absolute_error = abs ( b - a ) <EOL> except OverflowError : <EOL> pass <EOL> else : <EOL> if absolute_error <= max ( abs_err , rel_err * abs ( a ) ) : <EOL> return <EOL> self . fail ( msg or <EOL> '<STR_LIT>' . format ( a , b ) ) <EOL> def test_constants ( self ) : <EOL> e_expected = <NUM_LIT> <EOL> pi_expected = <NUM_LIT> <EOL> self . assertAlmostEqual ( cmath . pi , pi_expected , places = <NUM_LIT:9> , <EOL> msg = "<STR_LIT>" . format ( cmath . pi , pi_expected ) ) <EOL> self . assertAlmostEqual ( cmath . e , e_expected , places = <NUM_LIT:9> , <EOL> msg = "<STR_LIT>" . format ( cmath . e , e_expected ) ) <EOL> def test_user_object ( self ) : <EOL> cx_arg = <NUM_LIT> + <NUM_LIT> <EOL> flt_arg = - <NUM_LIT> <EOL> non_complexes = [ "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT> , None , <EOL> object ( ) , NotImplemented ] <EOL> class MyComplex ( object ) : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __complex__ ( self ) : <EOL> return self . value <EOL> class MyComplexOS : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __complex__ ( self ) : <EOL> return self . value <EOL> class SomeException ( Exception ) : <EOL> pass <EOL> class MyComplexException ( object ) : <EOL> def __complex__ ( self ) : <EOL> raise SomeException <EOL> class MyComplexExceptionOS : <EOL> def __complex__ ( self ) : <EOL> raise SomeException <EOL> class NeitherComplexNorFloat ( object ) : <EOL> pass <EOL> class NeitherComplexNorFloatOS : <EOL> pass <EOL> class MyInt ( object ) : <EOL> def __int__ ( self ) : return <NUM_LIT:2> <EOL> def __index__ ( self ) : return <NUM_LIT:2> <EOL> class MyIntOS : <EOL> def __int__ ( self ) : return <NUM_LIT:2> <EOL> def __index__ ( self ) : return <NUM_LIT:2> <EOL> class FloatAndComplex ( object ) : <EOL> def __float__ ( self ) : <EOL> return flt_arg <EOL> def __complex__ ( self ) : <EOL> return cx_arg <EOL> class FloatAndComplexOS : <EOL> def __float__ ( self ) : <EOL> return flt_arg <EOL> def __complex__ ( self ) : <EOL> return cx_arg <EOL> class JustFloat ( object ) : <EOL> def __float__ ( self ) : <EOL> return flt_arg <EOL> class JustFloatOS : <EOL> def __float__ ( self ) : <EOL> return flt_arg <EOL> for f in self . test_functions : <EOL> self . assertEqual ( f ( MyComplex ( cx_arg ) ) , f ( cx_arg ) ) <EOL> self . assertEqual ( f ( MyComplexOS ( cx_arg ) ) , f ( cx_arg ) ) <EOL> self . assertEqual ( f ( FloatAndComplex ( ) ) , f ( cx_arg ) ) <EOL> self . assertEqual ( f ( FloatAndComplexOS ( ) ) , f ( cx_arg ) ) <EOL> self . assertEqual ( f ( JustFloat ( ) ) , f ( flt_arg ) ) <EOL> self . assertEqual ( f ( JustFloatOS ( ) ) , f ( flt_arg ) ) <EOL> self . assertRaises ( TypeError , f , NeitherComplexNorFloat ( ) ) <EOL> self . assertRaises ( TypeError , f , MyInt ( ) ) <EOL> self . assertRaises ( Exception , f , NeitherComplexNorFloatOS ( ) ) <EOL> self . assertRaises ( Exception , f , MyIntOS ( ) ) <EOL> for bad_complex in non_complexes : <EOL> self . assertRaises ( TypeError , f , MyComplex ( bad_complex ) ) <EOL> self . assertRaises ( TypeError , f , MyComplexOS ( bad_complex ) ) <EOL> self . assertRaises ( SomeException , f , MyComplexException ( ) ) <EOL> self . assertRaises ( SomeException , f , MyComplexExceptionOS ( ) ) <EOL> def test_input_type ( self ) : <EOL> for f in self . test_functions : <EOL> for arg in [ <NUM_LIT:2> , <NUM_LIT> ] : <EOL> self . assertEqual ( f ( arg ) , f ( arg . __float__ ( ) ) ) <EOL> for f in self . test_functions : <EOL> for arg in [ "<STR_LIT:a>" , "<STR_LIT>" , "<STR_LIT:0>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> self . assertRaises ( TypeError , f , arg ) <EOL> def test_cmath_matches_math ( self ) : <EOL> test_values = [ <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> ] <EOL> unit_interval = test_values + [ - x for x in test_values ] + [ <NUM_LIT:0.> , <NUM_LIT:1.> , - <NUM_LIT:1.> ] <EOL> positive = test_values + [ <NUM_LIT:1.> ] + [ <NUM_LIT:1.> / x for x in test_values ] <EOL> nonnegative = [ <NUM_LIT:0.> ] + positive <EOL> real_line = [ <NUM_LIT:0.> ] + positive + [ - x for x in positive ] <EOL> test_functions = { <EOL> '<STR_LIT>' : unit_interval , <EOL> '<STR_LIT>' : unit_interval , <EOL> '<STR_LIT>' : real_line , <EOL> '<STR_LIT>' : real_line , <EOL> '<STR_LIT>' : real_line , <EOL> '<STR_LIT>' : real_line , <EOL> '<STR_LIT>' : positive , <EOL> '<STR_LIT>' : positive , <EOL> '<STR_LIT>' : real_line , <EOL> '<STR_LIT>' : real_line , <EOL> '<STR_LIT>' : nonnegative , <EOL> '<STR_LIT>' : real_line , <EOL> '<STR_LIT>' : real_line } <EOL> for fn , values in test_functions . items ( ) : <EOL> float_fn = getattr ( math , fn ) <EOL> complex_fn = getattr ( cmath , fn ) <EOL> for v in values : <EOL> z = complex_fn ( v ) <EOL> self . rAssertAlmostEqual ( float_fn ( v ) , z . real ) <EOL> self . assertEqual ( <NUM_LIT:0.> , z . imag ) <EOL> for base in [ <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> ] : <EOL> for v in positive : <EOL> z = cmath . log ( v , base ) <EOL> self . rAssertAlmostEqual ( math . log ( v , base ) , z . real ) <EOL> self . assertEqual ( <NUM_LIT:0.> , z . imag ) <EOL> @ requires_IEEE_754 <EOL> def test_specific_values ( self ) : <EOL> def rect_complex ( z ) : <EOL> """<STR_LIT>""" <EOL> return cmath . rect ( z . real , z . imag ) <EOL> def polar_complex ( z ) : <EOL> """<STR_LIT>""" <EOL> return complex ( * polar ( z ) ) <EOL> for id , fn , ar , ai , er , ei , flags in parse_testfile ( test_file ) : <EOL> arg = complex ( ar , ai ) <EOL> expected = complex ( er , ei ) <EOL> if fn == '<STR_LIT>' : <EOL> function = rect_complex <EOL> elif fn == '<STR_LIT>' : <EOL> function = polar_complex <EOL> else : <EOL> function = getattr ( cmath , fn ) <EOL> if '<STR_LIT>' in flags or '<STR_LIT>' in flags : <EOL> try : <EOL> actual = function ( arg ) <EOL> except ValueError : <EOL> continue <EOL> else : <EOL> self . fail ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( id , fn , ar , ai ) ) <EOL> if '<STR_LIT>' in flags : <EOL> try : <EOL> actual = function ( arg ) <EOL> except OverflowError : <EOL> continue <EOL> else : <EOL> self . fail ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( id , fn , ar , ai ) ) <EOL> actual = function ( arg ) <EOL> if '<STR_LIT>' in flags : <EOL> actual = complex ( abs ( actual . real ) , actual . imag ) <EOL> expected = complex ( abs ( expected . real ) , expected . imag ) <EOL> if '<STR_LIT>' in flags : <EOL> actual = complex ( actual . real , abs ( actual . imag ) ) <EOL> expected = complex ( expected . real , abs ( expected . imag ) ) <EOL> if fn in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> real_abs_err = <NUM_LIT> <EOL> else : <EOL> real_abs_err = <NUM_LIT> <EOL> error_message = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) . format ( id , fn , ar , ai , <EOL> expected . real , expected . imag , <EOL> actual . real , actual . imag ) <EOL> self . rAssertAlmostEqual ( expected . real , actual . real , <EOL> abs_err = real_abs_err , <EOL> msg = error_message ) <EOL> self . rAssertAlmostEqual ( expected . imag , actual . imag , <EOL> msg = error_message ) <EOL> def assertCISEqual ( self , a , b ) : <EOL> eps = <NUM_LIT> <EOL> if abs ( a [ <NUM_LIT:0> ] - b [ <NUM_LIT:0> ] ) > eps or abs ( a [ <NUM_LIT:1> ] - b [ <NUM_LIT:1> ] ) > eps : <EOL> self . fail ( ( a , b ) ) <EOL> def test_polar ( self ) : <EOL> self . assertCISEqual ( polar ( <NUM_LIT:0> ) , ( <NUM_LIT:0.> , <NUM_LIT:0.> ) ) <EOL> self . assertCISEqual ( polar ( <NUM_LIT:1.> ) , ( <NUM_LIT:1.> , <NUM_LIT:0.> ) ) <EOL> self . assertCISEqual ( polar ( - <NUM_LIT:1.> ) , ( <NUM_LIT:1.> , pi ) ) <EOL> self . assertCISEqual ( polar ( <NUM_LIT> ) , ( <NUM_LIT:1.> , pi / <NUM_LIT:2> ) ) <EOL> self . assertCISEqual ( polar ( - <NUM_LIT> ) , ( <NUM_LIT:1.> , - pi / <NUM_LIT:2> ) ) <EOL> def test_phase ( self ) : <EOL> self . assertAlmostEqual ( phase ( <NUM_LIT:0> ) , <NUM_LIT:0.> ) <EOL> self . assertAlmostEqual ( phase ( <NUM_LIT:1.> ) , <NUM_LIT:0.> ) <EOL> self . assertAlmostEqual ( phase ( - <NUM_LIT:1.> ) , pi ) <EOL> self . assertAlmostEqual ( phase ( - <NUM_LIT:1.> + <NUM_LIT> ) , pi ) <EOL> self . assertAlmostEqual ( phase ( - <NUM_LIT:1.> - <NUM_LIT> ) , - pi ) <EOL> self . assertAlmostEqual ( phase ( <NUM_LIT> ) , pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( - <NUM_LIT> ) , - pi / <NUM_LIT:2> ) <EOL> self . assertEqual ( phase ( complex ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) ) , <NUM_LIT:0.0> ) <EOL> self . assertEqual ( phase ( complex ( <NUM_LIT:0.0> , - <NUM_LIT:0.0> ) ) , - <NUM_LIT:0.0> ) <EOL> self . assertEqual ( phase ( complex ( - <NUM_LIT:0.0> , <NUM_LIT:0.0> ) ) , pi ) <EOL> self . assertEqual ( phase ( complex ( - <NUM_LIT:0.0> , - <NUM_LIT:0.0> ) ) , - pi ) <EOL> self . assertAlmostEqual ( phase ( complex ( - INF , - <NUM_LIT:0.0> ) ) , - pi ) <EOL> self . assertAlmostEqual ( phase ( complex ( - INF , - <NUM_LIT> ) ) , - pi ) <EOL> self . assertAlmostEqual ( phase ( complex ( - INF , - INF ) ) , - <NUM_LIT> * pi ) <EOL> self . assertAlmostEqual ( phase ( complex ( - <NUM_LIT> , - INF ) ) , - pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( - <NUM_LIT:0.0> , - INF ) ) , - pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( <NUM_LIT:0.0> , - INF ) ) , - pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( <NUM_LIT> , - INF ) ) , - pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( INF , - INF ) ) , - pi / <NUM_LIT:4> ) <EOL> self . assertEqual ( phase ( complex ( INF , - <NUM_LIT> ) ) , - <NUM_LIT:0.0> ) <EOL> self . assertEqual ( phase ( complex ( INF , - <NUM_LIT:0.0> ) ) , - <NUM_LIT:0.0> ) <EOL> self . assertEqual ( phase ( complex ( INF , <NUM_LIT:0.0> ) ) , <NUM_LIT:0.0> ) <EOL> self . assertEqual ( phase ( complex ( INF , <NUM_LIT> ) ) , <NUM_LIT:0.0> ) <EOL> self . assertAlmostEqual ( phase ( complex ( INF , INF ) ) , pi / <NUM_LIT:4> ) <EOL> self . assertAlmostEqual ( phase ( complex ( <NUM_LIT> , INF ) ) , pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( <NUM_LIT:0.0> , INF ) ) , pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( - <NUM_LIT:0.0> , INF ) ) , pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( - <NUM_LIT> , INF ) ) , pi / <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( phase ( complex ( - INF , INF ) ) , <NUM_LIT> * pi ) <EOL> self . assertAlmostEqual ( phase ( complex ( - INF , <NUM_LIT> ) ) , pi ) <EOL> self . assertAlmostEqual ( phase ( complex ( - INF , <NUM_LIT:0.0> ) ) , pi ) <EOL> for z in complex_nans : <EOL> self . assertTrue ( math . isnan ( phase ( z ) ) ) <EOL> def test_abs ( self ) : <EOL> for z in complex_zeros : <EOL> self . assertEqual ( abs ( z ) , <NUM_LIT:0.0> ) <EOL> for z in complex_infinities : <EOL> self . assertEqual ( abs ( z ) , INF ) <EOL> self . assertEqual ( abs ( complex ( NAN , - INF ) ) , INF ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( NAN , - <NUM_LIT> ) ) ) ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( NAN , - <NUM_LIT:0.0> ) ) ) ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( NAN , <NUM_LIT:0.0> ) ) ) ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( NAN , <NUM_LIT> ) ) ) ) <EOL> self . assertEqual ( abs ( complex ( NAN , INF ) ) , INF ) <EOL> self . assertEqual ( abs ( complex ( - INF , NAN ) ) , INF ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( - <NUM_LIT> , NAN ) ) ) ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( - <NUM_LIT:0.0> , NAN ) ) ) ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( <NUM_LIT:0.0> , NAN ) ) ) ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( <NUM_LIT> , NAN ) ) ) ) <EOL> self . assertEqual ( abs ( complex ( INF , NAN ) ) , INF ) <EOL> self . assertTrue ( math . isnan ( abs ( complex ( NAN , NAN ) ) ) ) <EOL> @ requires_IEEE_754 <EOL> def test_abs_overflows ( self ) : <EOL> self . assertRaises ( OverflowError , abs , complex ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> def assertCEqual ( self , a , b ) : <EOL> eps = <NUM_LIT> <EOL> if abs ( a . real - b [ <NUM_LIT:0> ] ) > eps or abs ( a . imag - b [ <NUM_LIT:1> ] ) > eps : <EOL> self . fail ( ( a , b ) ) <EOL> def test_rect ( self ) : <EOL> self . assertCEqual ( rect ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertCEqual ( rect ( <NUM_LIT:1> , <NUM_LIT:0> ) , ( <NUM_LIT:1.> , <NUM_LIT:0> ) ) <EOL> self . assertCEqual ( rect ( <NUM_LIT:1> , - pi ) , ( - <NUM_LIT:1.> , <NUM_LIT:0> ) ) <EOL> self . assertCEqual ( rect ( <NUM_LIT:1> , pi / <NUM_LIT:2> ) , ( <NUM_LIT:0> , <NUM_LIT:1.> ) ) <EOL> self . assertCEqual ( rect ( <NUM_LIT:1> , - pi / <NUM_LIT:2> ) , ( <NUM_LIT:0> , - <NUM_LIT:1.> ) ) <EOL> def test_isfinite ( self ) : <EOL> real_vals = [ float ( '<STR_LIT>' ) , - <NUM_LIT> , - <NUM_LIT:0.0> , <EOL> <NUM_LIT:0.0> , <NUM_LIT> , float ( '<STR_LIT>' ) , float ( '<STR_LIT>' ) ] <EOL> for x in real_vals : <EOL> for y in real_vals : <EOL> z = complex ( x , y ) <EOL> self . assertEqual ( cmath . isfinite ( z ) , <EOL> math . isfinite ( x ) and math . isfinite ( y ) ) <EOL> def test_isnan ( self ) : <EOL> self . assertFalse ( cmath . isnan ( <NUM_LIT:1> ) ) <EOL> self . assertFalse ( cmath . isnan ( <NUM_LIT> ) ) <EOL> self . assertFalse ( cmath . isnan ( INF ) ) <EOL> self . assertTrue ( cmath . isnan ( NAN ) ) <EOL> self . assertTrue ( cmath . isnan ( complex ( NAN , <NUM_LIT:0> ) ) ) <EOL> self . assertTrue ( cmath . isnan ( complex ( <NUM_LIT:0> , NAN ) ) ) <EOL> self . assertTrue ( cmath . isnan ( complex ( NAN , NAN ) ) ) <EOL> self . assertTrue ( cmath . isnan ( complex ( NAN , INF ) ) ) <EOL> self . assertTrue ( cmath . isnan ( complex ( INF , NAN ) ) ) <EOL> def test_isinf ( self ) : <EOL> self . assertFalse ( cmath . isinf ( <NUM_LIT:1> ) ) <EOL> self . assertFalse ( cmath . isinf ( <NUM_LIT> ) ) <EOL> self . assertFalse ( cmath . isinf ( NAN ) ) <EOL> self . assertTrue ( cmath . isinf ( INF ) ) <EOL> self . assertTrue ( cmath . isinf ( complex ( INF , <NUM_LIT:0> ) ) ) <EOL> self . assertTrue ( cmath . isinf ( complex ( <NUM_LIT:0> , INF ) ) ) <EOL> self . assertTrue ( cmath . isinf ( complex ( INF , INF ) ) ) <EOL> self . assertTrue ( cmath . isinf ( complex ( NAN , INF ) ) ) <EOL> self . assertTrue ( cmath . isinf ( complex ( INF , NAN ) ) ) <EOL> @ requires_IEEE_754 <EOL> @ unittest . skipIf ( sysconfig . get_config_var ( '<STR_LIT>' ) == <NUM_LIT:0> , <EOL> "<STR_LIT>" ) <EOL> def testTanhSign ( self ) : <EOL> for z in complex_zeros : <EOL> self . assertComplexIdentical ( cmath . tanh ( z ) , z ) <EOL> @ requires_IEEE_754 <EOL> def testAtanSign ( self ) : <EOL> for z in complex_zeros : <EOL> self . assertComplexIdentical ( cmath . atan ( z ) , z ) <EOL> @ requires_IEEE_754 <EOL> def testAtanhSign ( self ) : <EOL> for z in complex_zeros : <EOL> self . assertComplexIdentical ( cmath . atanh ( z ) , z ) <EOL> def test_main ( ) : <EOL> run_unittest ( CMathTests ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
