@@ -32,13 +32,7 @@ def test_binary_ops(op, other):
32
32
quad_result = op_func (quad_a , quad_b )
33
33
float_result = op_func (float_a , float_b )
34
34
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 )
42
36
43
37
44
38
@pytest .mark .parametrize ("op" , ["eq" , "ne" , "le" , "lt" , "ge" , "gt" ])
@@ -83,9 +77,7 @@ def test_array_minmax(op, a, b):
83
77
quad_res = op_func (quad_a , quad_b )
84
78
float_res = op_func (float_a , float_b )
85
79
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 )
89
81
90
82
91
83
@pytest .mark .parametrize ("op" , ["amin" , "amax" , "nanmin" , "nanmax" ])
@@ -102,12 +94,10 @@ def test_array_aminmax(op, a, b):
102
94
quad_res = op_func (quad_ab )
103
95
float_res = op_func (float_ab )
104
96
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 )
108
98
109
99
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" ) ])
111
101
@pytest .mark .parametrize ("val" , ["3.0" , "-3.0" , "12.5" , "100.0" , "0.0" , "-0.0" , "inf" , "-inf" , "nan" , "-nan" ])
112
102
def test_unary_ops (op , nop , val ):
113
103
op_func = None if op is None else getattr (operator , op )
@@ -123,14 +113,8 @@ def test_unary_ops(op, nop, val):
123
113
quad_result = op_func (quad_val )
124
114
float_result = op_func (float_val )
125
115
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 )
134
118
135
119
136
120
def test_inf ():
0 commit comments