Skip to content

Commit 840adaa

Browse files
Add test for using float as key in getitem
1 parent 65ceb12 commit 840adaa

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,3 +2416,25 @@ def test_asarray_writable_flag(ro_flag):
24162416

24172417
assert b.flags["W"] == (not ro_flag)
24182418
assert b._pointer == a._pointer
2419+
2420+
2421+
def test_getitem_validation():
2422+
"""Test based on gh-1785"""
2423+
try:
2424+
a = dpt.empty((2, 2, 2))
2425+
except dpctl.SyclDeviceCreationError:
2426+
pytest.skip("No SYCL devices available")
2427+
with pytest.raises(IndexError):
2428+
a[0.0]
2429+
with pytest.raises(IndexError):
2430+
a[1, 0.0, ...]
2431+
with pytest.raises(IndexError):
2432+
a[1, 0.0, dpt.newaxis, 1]
2433+
with pytest.raises(IndexError):
2434+
a[dpt.newaxis, ..., 0.0]
2435+
with pytest.raises(IndexError):
2436+
a[dpt.newaxis, ..., 0.0, dpt.newaxis]
2437+
with pytest.raises(IndexError):
2438+
a[..., 0.0, dpt.newaxis]
2439+
with pytest.raises(IndexError):
2440+
a[:, 0.0, dpt.newaxis]

0 commit comments

Comments
 (0)