Skip to content

Commit 7e11d06

Browse files
Made explicit wrapping behavior of out of bound values of sorter
tensor.searchsorter apply sorter array, if present, to first input array using tensor.take with default mode="wrap", which replaces out of bound indices with in-bound ones using modular reduction.
1 parent ccb64a5 commit 7e11d06

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dpctl/tensor/_searchsorted.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def searchsorted(
2222
*,
2323
side: Literal["left", "right"] = "left",
2424
sorter: Union[usm_ndarray, None] = None,
25-
):
25+
) -> usm_ndarray:
2626
"""searchsorted(x1, x2, side='left', sorter=None)
2727
2828
Finds the indices into `x1` such that, if the corresponding elements
@@ -50,6 +50,9 @@ def searchsorted(
5050
sorter (Optional[usm_ndarray]):
5151
array of indices that sort `x1` in ascending order. The array must
5252
have the same shape as `x1` and have an integral data type.
53+
Out of bound index values of `sorter` array are treated using
54+
`"wrap"` mode documented in :func:`dpctl.tensor.take`, i.e.
55+
replaced with `sorter[i] % x1.shape[0]`.
5356
Default: `None`.
5457
"""
5558
if not isinstance(x1, usm_ndarray):

0 commit comments

Comments
 (0)