(N, dtype)
| 11286 | @pytest.mark.parametrize("dtype", [np.int16, np.uint16, |
| 11287 | np.int32, np.uint32, np.int64, np.uint64]) |
| 11288 | def test_partition_int(N, dtype): |
| 11289 | rnd = np.random.RandomState(1100710816) |
| 11290 | # (1) random data with min and max values |
| 11291 | minv = np.iinfo(dtype).min |
| 11292 | maxv = np.iinfo(dtype).max |
| 11293 | arr = rnd.randint(low=minv, high=maxv, size=N, dtype=dtype) |
| 11294 | i, j = rnd.choice(N, 2, replace=False) |
| 11295 | arr[i] = minv |
| 11296 | arr[j] = maxv |
| 11297 | k = rnd.choice(N, 1)[0] |
| 11298 | assert_arr_partitioned(np.sort(arr)[k], k, |
| 11299 | np.partition(arr, k, kind='introselect')) |
| 11300 | assert_arr_partitioned(np.sort(arr)[k], k, |
| 11301 | arr[np.argpartition(arr, k, kind='introselect')]) |
| 11302 | |
| 11303 | # (2) random data with max value at the end of array |
| 11304 | arr = rnd.randint(low=minv, high=maxv, size=N, dtype=dtype) |
| 11305 | arr[N - 1] = maxv |
| 11306 | assert_arr_partitioned(np.sort(arr)[k], k, |
| 11307 | np.partition(arr, k, kind='introselect')) |
| 11308 | assert_arr_partitioned(np.sort(arr)[k], k, |
| 11309 | arr[np.argpartition(arr, k, kind='introselect')]) |
| 11310 | |
| 11311 | |
| 11312 | @pytest.mark.parametrize("N", np.arange(2, 512)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…