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

Function test_sort_indices_array

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

Source from the content-addressed store, hash-verified

3369
3370
3371def test_sort_indices_array():
3372 arr = pa.array([1, 2, None, 0])
3373 result = pc.sort_indices(arr)
3374 assert result.to_pylist() == [3, 0, 1, 2]
3375 result = pc.sort_indices(arr, sort_keys=[("dummy", "ascending", "at_end")])
3376 assert result.to_pylist() == [3, 0, 1, 2]
3377 result = pc.sort_indices(arr, sort_keys=[("dummy", "descending", "at_end")])
3378 assert result.to_pylist() == [1, 0, 3, 2]
3379 result = pc.sort_indices(arr, sort_keys=[("dummy", "descending", "at_start")])
3380 assert result.to_pylist() == [2, 1, 0, 3]
3381 # Positional `sort_keys`
3382 result = pc.sort_indices(arr, [("dummy", "descending", "at_start")])
3383 assert result.to_pylist() == [2, 1, 0, 3]
3384 # Using SortOptions
3385 result = pc.sort_indices(
3386 arr, options=pc.SortOptions(sort_keys=[("dummy", "descending", "at_end")])
3387 )
3388 assert result.to_pylist() == [1, 0, 3, 2]
3389 result = pc.sort_indices(
3390 arr, options=pc.SortOptions(sort_keys=[("dummy", "descending", "at_start")])
3391 )
3392 assert result.to_pylist() == [2, 1, 0, 3]
3393
3394
3395def test_sort_indices_table():

Callers

nothing calls this directly

Calls 2

SortOptionsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected