@@ -32,13 +32,7 @@ def test_binary_ops(op, other):
3232 quad_result = op_func (quad_a , quad_b )
3333 float_result = op_func (float_a , float_b )
3434
35- # FIXME: @juntyr: replace with array_equal once isnan is supported
36- with np .errstate (invalid = "ignore" ):
37- assert (
38- (np .float64 (quad_result ) == float_result ) or
39- (np .abs (np .float64 (quad_result ) - float_result ) < 1e-10 ) or
40- ((float_result != float_result ) and (quad_result != quad_result ))
41- )
35+ np .testing .assert_allclose (np .float64 (quad_result ), float_result , atol = 1e-10 , rtol = 0 , equal_nan = True )
4236
4337
4438@pytest .mark .parametrize ("op" , ["eq" , "ne" , "le" , "lt" , "ge" , "gt" ])
@@ -83,9 +77,7 @@ def test_array_minmax(op, a, b):
8377 quad_res = op_func (quad_a , quad_b )
8478 float_res = op_func (float_a , float_b )
8579
86- # FIXME: @juntyr: replace with array_equal once isnan is supported
87- with np .errstate (invalid = "ignore" ):
88- assert np .all ((quad_res == float_res ) | ((quad_res != quad_res ) & (float_res != float_res )))
80+ np .testing .assert_array_equal (quad_res .astype (float ), float_res )
8981
9082
9183@pytest .mark .parametrize ("op" , ["amin" , "amax" , "nanmin" , "nanmax" ])
@@ -102,12 +94,10 @@ def test_array_aminmax(op, a, b):
10294 quad_res = op_func (quad_ab )
10395 float_res = op_func (float_ab )
10496
105- # FIXME: @juntyr: replace with array_equal once isnan is supported
106- with np .errstate (invalid = "ignore" ):
107- assert np .all ((quad_res == float_res ) | ((quad_res != quad_res ) & (float_res != float_res )))
97+ np .testing .assert_array_equal (np .array (quad_res ).astype (float ), float_res )
10898
10999
110- @pytest .mark .parametrize ("op,nop" , [("neg" , "negative" ), ("pos" , "positive" ), ("abs" , "absolute" ), (None , "sign" ), (None , "signbit" )])
100+ @pytest .mark .parametrize ("op,nop" , [("neg" , "negative" ), ("pos" , "positive" ), ("abs" , "absolute" ), (None , "sign" ), (None , "signbit" ), ( None , "isfinite" ), ( None , "isinf" ), ( None , "isnan" ) ])
111101@pytest .mark .parametrize ("val" , ["3.0" , "-3.0" , "12.5" , "100.0" , "0.0" , "-0.0" , "inf" , "-inf" , "nan" , "-nan" ])
112102def test_unary_ops (op , nop , val ):
113103 op_func = None if op is None else getattr (operator , op )
@@ -123,14 +113,8 @@ def test_unary_ops(op, nop, val):
123113 quad_result = op_func (quad_val )
124114 float_result = op_func (float_val )
125115
126- # FIXME: @juntyr: replace with array_equal once isnan is supported
127- with np .errstate (invalid = "ignore" ):
128- assert (
129- (np .float64 (quad_result ) == float_result ) or
130- ((float_result != float_result ) and (quad_result != quad_result ))
131- ) and (
132- np .signbit (float_result ) == np .signbit (quad_result )
133- ), f"{ op } ({ val } ) should be { float_result } , but got { quad_result } "
116+ np .testing .assert_array_equal (np .array (quad_result ).astype (float ), float_result )
117+ assert np .signbit (float_result ) == np .signbit (quad_result )
134118
135119
136120def test_inf ():
0 commit comments