Skip to content

Commit 23c61a8

Browse files
committed
Add test covering nans and +/- 0 in isin
1 parent aa957b6 commit 23c61a8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

dpctl/tests/test_tensor_isin.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,22 @@ def test_isin_empty_inputs():
173173
def test_isin_validation():
174174
with pytest.raises(ExecutionPlacementError):
175175
dpt.isin(1, 1)
176+
177+
178+
def test_isin_special_floating_point_vals():
179+
get_queue_or_skip()
180+
181+
# real and complex nans compare false
182+
x = dpt.asarray(dpt.nan, dtype="f4")
183+
test = dpt.asarray(dpt.nan, dtype="f4")
184+
assert not dpt.isin(x, test)
185+
186+
x = dpt.asarray(dpt.nan, dtype="c8")
187+
test = dpt.asarray(dpt.nan, dtype="c8")
188+
assert not dpt.isin(x, test)
189+
190+
# -0.0 compares equal to +0.0
191+
x = dpt.asarray(-0.0, dtype="f4")
192+
test = dpt.asarray(0.0, dtype="f4")
193+
assert dpt.isin(x, test)
194+
assert dpt.isin(test, x)

0 commit comments

Comments
 (0)