Skip to content

Commit dd36894

Browse files
Added test for out of bounds indices in sorter
1 parent 9962dd2 commit dd36894

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dpctl/tests/test_usm_ndarray_searchsorted.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,18 @@ def test_pw_linear_interpolation_example():
340340
exp = dpt.vecdot(vals[1:] + vals[:-1], bins[1:] - bins[:-1]) / 2
341341

342342
assert dpt.abs(av - exp) < 0.1
343+
344+
345+
def test_out_of_bound_sorter_values():
346+
get_queue_or_skip()
347+
348+
x = dpt.asarray([1, 2, 0], dtype="i4")
349+
n = x.shape[0]
350+
351+
# use out-of-bounds indices in sorter
352+
sorter = dpt.asarray([2, 0 - n, 1 - n], dtype="i8")
353+
354+
x2 = dpt.arange(3, dtype=x.dtype)
355+
p = dpt.searchsorted(x, x2, sorter=sorter)
356+
# verify that they were applied with mode="wrap"
357+
assert dpt.all(p == dpt.arange(3, dtype=p.dtype))

0 commit comments

Comments
 (0)