MCPcopy Create free account
hub / github.com/apache/arrow / test_search_sorted

Function test_search_sorted

python/pyarrow/tests/test_compute.py:3281–3298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3279
3280
3281def test_search_sorted():
3282 values = pa.array([1, 1, 3, 5, 8])
3283 needles = pa.array([0, 1, 3, 4, 5, 8, 9])
3284
3285 expected_left = pa.array([0, 0, 2, 3, 3, 4, 5], type=pa.uint64())
3286 expected_right = pa.array([0, 2, 3, 3, 4, 5, 5], type=pa.uint64())
3287
3288 assert pc.search_sorted(values, needles).equals(expected_left)
3289 assert pc.search_sorted(values, needles, side="left").equals(expected_left)
3290 assert pc.search_sorted(values, needles, "right").equals(expected_right)
3291 assert pc.search_sorted(
3292 values, needles, options=pc.SearchSortedOptions(side="right")
3293 ).equals(expected_right)
3294
3295 assert pc.search_sorted(values, pa.scalar(5, type=pa.int64())).as_py() == 3
3296 assert pc.search_sorted(
3297 values, pa.scalar(5, type=pa.int64()), side="right"
3298 ).as_py() == 4
3299
3300
3301def test_search_sorted_null_values():

Callers

nothing calls this directly

Calls 5

equalsMethod · 0.80
SearchSortedOptionsMethod · 0.80
as_pyMethod · 0.80
arrayMethod · 0.45
scalarMethod · 0.45

Tested by

no test coverage detected