MCPcopy Create free account
hub / github.com/numpy/numpy / test_partition_fuzz

Method test_partition_fuzz

numpy/core/tests/test_multiarray.py:3102–3113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3100 assert_raises(ValueError, d.argpartition, 2, kind=k)
3101
3102 def test_partition_fuzz(self):
3103 # a few rounds of random data testing
3104 for j in range(10, 30):
3105 for i in range(1, j - 2):
3106 d = np.arange(j)
3107 np.random.shuffle(d)
3108 d = d % np.random.randint(2, 30)
3109 idx = np.random.randint(d.size)
3110 kth = [0, idx, i, i + 1]
3111 tgt = np.sort(d)[kth]
3112 assert_array_equal(np.partition(d, kth)[kth], tgt,
3113 err_msg="data: %r\n kth: %r" % (d, kth))
3114
3115 @pytest.mark.parametrize("kth_dtype", np.typecodes["AllInteger"])
3116 def test_argpartition_gh5524(self, kth_dtype):

Callers

nothing calls this directly

Calls 3

assert_array_equalFunction · 0.90
sortMethod · 0.80
partitionMethod · 0.45

Tested by

no test coverage detected