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

Function test_sort_indices_array

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

Source from the content-addressed store, hash-verified

3022
3023
3024def test_sort_indices_array():
3025 arr = pa.array([1, 2, None, 0])
3026 result = pc.sort_indices(arr)
3027 assert result.to_pylist() == [3, 0, 1, 2]
3028 result = pc.sort_indices(arr, sort_keys=[("dummy", "ascending")])
3029 assert result.to_pylist() == [3, 0, 1, 2]
3030 result = pc.sort_indices(arr, sort_keys=[("dummy", "descending")])
3031 assert result.to_pylist() == [1, 0, 3, 2]
3032 result = pc.sort_indices(arr, sort_keys=[("dummy", "descending")],
3033 null_placement="at_start")
3034 assert result.to_pylist() == [2, 1, 0, 3]
3035 # Positional `sort_keys`
3036 result = pc.sort_indices(arr, [("dummy", "descending")],
3037 null_placement="at_start")
3038 assert result.to_pylist() == [2, 1, 0, 3]
3039 # Using SortOptions
3040 result = pc.sort_indices(
3041 arr, options=pc.SortOptions(sort_keys=[("dummy", "descending")])
3042 )
3043 assert result.to_pylist() == [1, 0, 3, 2]
3044 result = pc.sort_indices(
3045 arr, options=pc.SortOptions(sort_keys=[("dummy", "descending")],
3046 null_placement="at_start")
3047 )
3048 assert result.to_pylist() == [2, 1, 0, 3]
3049
3050
3051def test_sort_indices_table():

Callers

nothing calls this directly

Calls 2

SortOptionsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected