Skip to content

Commit 5738b59

Browse files
committed
Use cmath.isnan instead of math.isnan in test_set_functions.py
1 parent 6fb104a commit 5738b59

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

array_api_tests/test_set_functions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_unique_all(x):
112112

113113
if dh.is_float_dtype(out.values.dtype):
114114
assume(math.prod(x.shape) <= 128) # may not be representable
115-
expected = sum(v for k, v in counts.items() if math.isnan(k))
115+
expected = sum(v for k, v in counts.items() if cmath.isnan(k))
116116
assert nans == expected, f"{nans} NaNs in out, but should be {expected}"
117117

118118

@@ -137,7 +137,7 @@ def test_unique_counts(x):
137137
for idx in sh.ndindex(out.values.shape):
138138
val = scalar_type(out.values[idx])
139139
count = int(out.counts[idx])
140-
if math.isnan(val):
140+
if cmath.isnan(val):
141141
nans += 1
142142
assert count == 1, (
143143
f"out.counts[{idx}]={count} for out.values[{idx}]={val}, "
@@ -159,7 +159,7 @@ def test_unique_counts(x):
159159
vals_idx[val] = idx
160160
if dh.is_float_dtype(out.values.dtype):
161161
assume(math.prod(x.shape) <= 128) # may not be representable
162-
expected = sum(v for k, v in counts.items() if math.isnan(k))
162+
expected = sum(v for k, v in counts.items() if cmath.isnan(k))
163163
assert nans == expected, f"{nans} NaNs in out, but should be {expected}"
164164

165165

@@ -188,7 +188,7 @@ def test_unique_inverse(x):
188188
nans = 0
189189
for idx in sh.ndindex(out.values.shape):
190190
val = scalar_type(out.values[idx])
191-
if math.isnan(val):
191+
if cmath.isnan(val):
192192
nans += 1
193193
else:
194194
assert (

0 commit comments

Comments
 (0)