(data, indices, pivot, null_placement)
| 3113 | |
| 3114 | |
| 3115 | def 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 | |
| 3136 | def test_partition_nth(): |
no test coverage detected