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

Function check_partition_nth

python/pyarrow/tests/test_compute.py:3115–3133  ·  view source on GitHub ↗
(data, indices, pivot, null_placement)

Source from the content-addressed store, hash-verified

3113
3114
3115def check_partition_nth(data, indices, pivot, null_placement):
3116 indices = indices.to_pylist()
3117 assert len(indices) == len(data)
3118 assert sorted(indices) == list(range(len(data)))
3119 until_pivot = [data[indices[i]] for i in range(pivot)]
3120 after_pivot = [data[indices[i]] for i in range(pivot, len(data))]
3121 p = data[indices[pivot]]
3122 if p is None:
3123 if null_placement == "at_start":
3124 assert all(v is None for v in until_pivot)
3125 else:
3126 assert all(v is None for v in after_pivot)
3127 else:
3128 if null_placement == "at_start":
3129 assert all(v is None or v <= p for v in until_pivot)
3130 assert all(v >= p for v in after_pivot)
3131 else:
3132 assert all(v <= p for v in until_pivot)
3133 assert all(v is None or v >= p for v in after_pivot)
3134
3135
3136def test_partition_nth():

Callers 2

test_partition_nthFunction · 0.85

Calls 2

lenFunction · 0.85
listFunction · 0.85

Tested by

no test coverage detected