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

Function validate_select_k

python/pyarrow/tests/test_compute.py:3163–3173  ·  view source on GitHub ↗
(select_k_indices, arr, order, null_placement="at_end",
                          stable_sort=False)

Source from the content-addressed store, hash-verified

3161
3162def test_select_k_array():
3163 def validate_select_k(select_k_indices, arr, order, null_placement="at_end",
3164 stable_sort=False):
3165 sorted_indices = pc.sort_indices(
3166 arr, sort_keys=[("dummy", order, null_placement)])
3167 head_k_indices = sorted_indices.slice(0, len(select_k_indices))
3168 if stable_sort:
3169 assert select_k_indices == head_k_indices
3170 else:
3171 expected = pc.take(arr, head_k_indices)
3172 actual = pc.take(arr, select_k_indices)
3173 assert actual == expected
3174
3175 arr = pa.array([1, 2, None, 0])
3176 for k in [0, 2, 4]:

Callers 2

test_select_k_arrayFunction · 0.85
test_select_k_tableFunction · 0.85

Calls 3

lenFunction · 0.85
sliceMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected