@@ -44,13 +44,7 @@ def test_binary_ops(op, other):
4444 quad_result = op_func (quad_a , quad_b )
4545 float_result = op_func (float_a , float_b )
4646
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 )
5448
5549
5650@pytest .mark .parametrize ("op" , ["eq" , "ne" , "le" , "lt" , "ge" , "gt" ])
@@ -95,9 +89,7 @@ def test_array_minmax(op, a, b):
9589 quad_res = op_func (quad_a , quad_b )
9690 float_res = op_func (float_a , float_b )
9791
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 )
10193
10294
10395@pytest .mark .parametrize ("op" , ["amin" , "amax" , "nanmin" , "nanmax" ])
@@ -114,12 +106,10 @@ def test_array_aminmax(op, a, b):
114106 quad_res = op_func (quad_ab )
115107 float_res = op_func (float_ab )
116108
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 )
120110
121111
122- @pytest .mark .parametrize ("op" , ["negative" , "positive" , "absolute" , "sign" , "signbit" ])
112+ @pytest .mark .parametrize ("op" , ["negative" , "positive" , "absolute" , "sign" , "signbit" , "isfinite" , "isinf" , "isnan" ])
123113@pytest .mark .parametrize ("val" , ["3.0" , "-3.0" , "12.5" , "100.0" , "0.0" , "-0.0" , "inf" , "-inf" , "nan" , "-nan" ])
124114def test_unary_ops (op , val ):
125115 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):
135125 quad_result = of (quad_val )
136126 float_result = of (float_val )
137127
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 )
146130
147131
148132def test_inf ():
0 commit comments