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

Function test_sort_indices_array

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

Source from the content-addressed store, hash-verified

3227
3228
3229def test_sort_indices_array():
3230 arr = pa.array([1, 2, None, 0])
3231 result = pc.sort_indices(arr)
3232 assert result.to_pylist() == [3, 0, 1, 2]
3233 result = pc.sort_indices(arr, sort_keys=[("dummy", "ascending", "at_end")])
3234 assert result.to_pylist() == [3, 0, 1, 2]
3235 result = pc.sort_indices(arr, sort_keys=[("dummy", "descending", "at_end")])
3236 assert result.to_pylist() == [1, 0, 3, 2]
3237 result = pc.sort_indices(arr, sort_keys=[("dummy", "descending", "at_start")])
3238 assert result.to_pylist() == [2, 1, 0, 3]
3239 # Positional `sort_keys`
3240 result = pc.sort_indices(arr, [("dummy", "descending", "at_start")])
3241 assert result.to_pylist() == [2, 1, 0, 3]
3242 # Using SortOptions
3243 result = pc.sort_indices(
3244 arr, options=pc.SortOptions(sort_keys=[("dummy", "descending", "at_end")])
3245 )
3246 assert result.to_pylist() == [1, 0, 3, 2]
3247 result = pc.sort_indices(
3248 arr, options=pc.SortOptions(sort_keys=[("dummy", "descending", "at_start")])
3249 )
3250 assert result.to_pylist() == [2, 1, 0, 3]
3251
3252
3253def test_sort_indices_table():

Callers

nothing calls this directly

Calls 2

SortOptionsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected