@@ -44,13 +44,7 @@ def test_binary_ops(op, other):
44
44
quad_result = op_func (quad_a , quad_b )
45
45
float_result = op_func (float_a , float_b )
46
46
47
- # FIXME: @juntyr: replace with array_equal once isnan is supported
48
- with np .errstate (invalid = "ignore" ):
49
- assert (
50
- (np .float64 (quad_result ) == float_result ) or
51
- (np .abs (np .float64 (quad_result ) - float_result ) < 1e-10 ) or
52
- ((float_result != float_result ) and (quad_result != quad_result ))
53
- )
47
+ np .testing .assert_allclose (np .float64 (quad_result ), float_result , atol = 1e-10 , rtol = 0 , equal_nan = True )
54
48
55
49
56
50
@pytest .mark .parametrize ("op" , ["eq" , "ne" , "le" , "lt" , "ge" , "gt" ])
@@ -95,9 +89,7 @@ def test_array_minmax(op, a, b):
95
89
quad_res = op_func (quad_a , quad_b )
96
90
float_res = op_func (float_a , float_b )
97
91
98
- # FIXME: @juntyr: replace with array_equal once isnan is supported
99
- with np .errstate (invalid = "ignore" ):
100
- assert np .all ((quad_res == float_res ) | ((quad_res != quad_res ) & (float_res != float_res )))
92
+ np .testing .assert_array_equal (quad_res .astype (float ), float_res )
101
93
102
94
103
95
@pytest .mark .parametrize ("op" , ["amin" , "amax" , "nanmin" , "nanmax" ])
@@ -114,12 +106,10 @@ def test_array_aminmax(op, a, b):
114
106
quad_res = op_func (quad_ab )
115
107
float_res = op_func (float_ab )
116
108
117
- # FIXME: @juntyr: replace with array_equal once isnan is supported
118
- with np .errstate (invalid = "ignore" ):
119
- assert np .all ((quad_res == float_res ) | ((quad_res != quad_res ) & (float_res != float_res )))
109
+ np .testing .assert_array_equal (np .array (quad_res ).astype (float ), float_res )
120
110
121
111
122
- @pytest .mark .parametrize ("op" , ["negative" , "positive" , "absolute" , "sign" , "signbit" ])
112
+ @pytest .mark .parametrize ("op" , ["negative" , "positive" , "absolute" , "sign" , "signbit" , "isfinite" , "isinf" , "isnan" ])
123
113
@pytest .mark .parametrize ("val" , ["3.0" , "-3.0" , "12.5" , "100.0" , "0.0" , "-0.0" , "inf" , "-inf" , "nan" , "-nan" ])
124
114
def test_unary_ops (op , val ):
125
115
op_func = dict (negative = operator .neg , positive = operator .pos , absolute = operator .abs ).get (op , None )
@@ -135,14 +125,8 @@ def test_unary_ops(op, val):
135
125
quad_result = of (quad_val )
136
126
float_result = of (float_val )
137
127
138
- # FIXME: @juntyr: replace with array_equal once isnan is supported
139
- with np .errstate (invalid = "ignore" ):
140
- assert (
141
- (np .float64 (quad_result ) == float_result ) or
142
- ((float_result != float_result ) and (quad_result != quad_result ))
143
- ) and (
144
- np .signbit (float_result ) == np .signbit (quad_result )
145
- ), f"{ op } ({ val } ) should be { float_result } , but got { quad_result } "
128
+ np .testing .assert_array_equal (np .array (quad_result ).astype (float ), float_result )
129
+ assert np .signbit (float_result ) == np .signbit (quad_result )
146
130
147
131
148
132
def test_inf ():
0 commit comments