Skip to content

Commit 33b0efe

Browse files
committed
ENH: test side=left,right in searchsorted
1 parent 0c5d449 commit 33b0efe

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

array_api_tests/test_searching_functions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ def test_where(shapes, dtypes, data):
243243
@pytest.mark.min_version("2023.12")
244244
@given(data=st.data())
245245
def test_searchsorted(data):
246-
# TODO: test side="right"
247246
# TODO: Allow different dtypes for x1 and x2
248247
_x1 = data.draw(
249248
st.lists(xps.from_dtype(dh.default_float), min_size=1, unique=True),
@@ -262,18 +261,22 @@ def test_searchsorted(data):
262261
),
263262
label="x2",
264263
)
264+
kw = data.draw(hh.kwargs(side=st.sampled_from(["left", "right"])))
265265

266-
repro_snippet = ph.format_snippet(f"xp.searchsorted({x1!r}, {x2!r}, sorter={sorter!r})")
266+
repro_snippet = ph.format_snippet(
267+
f"xp.searchsorted({x1!r}, {x2!r}, sorter={sorter!r}, **kw) with {kw=}"
268+
)
267269
try:
268-
out = xp.searchsorted(x1, x2, sorter=sorter)
270+
out = xp.searchsorted(x1, x2, sorter=sorter, **kw)
269271

270272
ph.assert_dtype(
271273
"searchsorted",
272274
in_dtype=[x1.dtype, x2.dtype],
273275
out_dtype=out.dtype,
274276
expected=xp.__array_namespace_info__().default_dtypes()["indexing"],
275277
)
276-
# TODO: shapes and values testing
278+
# TODO: x2.ndim > 1, values testing
279+
ph.assert_shape("searchsorted", out_shape=out.shape, expected=x2.shape)
277280
except Exception as exc:
278281
exc.add_note(repro_snippet)
279282
raise

0 commit comments

Comments
 (0)