MCPcopy
hub / github.com/numpy/numpy / test_partition_fp

Function test_partition_fp

numpy/_core/tests/test_multiarray.py:11314–11331  ·  view source on GitHub ↗
(N, dtype)

Source from the content-addressed store, hash-verified

11312@pytest.mark.parametrize("N", np.arange(2, 512))
11313@pytest.mark.parametrize("dtype", [np.float16, np.float32, np.float64])
11314def test_partition_fp(N, dtype):
11315 rnd = np.random.RandomState(1100710816)
11316 arr = -0.5 + rnd.random(N).astype(dtype)
11317 k = rnd.choice(N, 1)[0]
11318 assert_arr_partitioned(np.sort(arr)[k], k,
11319 np.partition(arr, k, kind='introselect'))
11320 assert_arr_partitioned(np.sort(arr)[k], k,
11321 arr[np.argpartition(arr, k, kind='introselect')])
11322
11323 # Check that `np.inf < np.nan`
11324 # This follows np.sort
11325 arr[0] = np.nan
11326 arr[1] = np.inf
11327 o1 = np.partition(arr, -2, kind='introselect')
11328 o2 = arr[np.argpartition(arr, -2, kind='introselect')]
11329 for out in [o1, o2]:
11330 assert_(np.isnan(out[-1]))
11331 assert_equal(out[-2], np.inf)
11332
11333def test_cannot_assign_data():
11334 a = np.arange(10)

Callers

nothing calls this directly

Calls 8

assert_Function · 0.90
assert_equalFunction · 0.90
assert_arr_partitionedFunction · 0.85
astypeMethod · 0.80
randomMethod · 0.80
argpartitionMethod · 0.80
sortMethod · 0.45
partitionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…