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

Method test_shuffle_masked

numpy/random/tests/test_random.py:506–518  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

504 assert_array_equal(actual, desired)
505
506 def test_shuffle_masked(self):
507 # gh-3263
508 a = np.ma.masked_values(np.reshape(range(20), (5, 4)) % 3 - 1, -1)
509 b = np.ma.masked_values(np.arange(20) % 3 - 1, -1)
510 a_orig = a.copy()
511 b_orig = b.copy()
512 for i in range(50):
513 np.random.shuffle(a)
514 assert_equal(
515 sorted(a.data[~a.mask]), sorted(a_orig.data[~a_orig.mask]))
516 np.random.shuffle(b)
517 assert_equal(
518 sorted(b.data[~b.mask]), sorted(b_orig.data[~b_orig.mask]))
519
520 @pytest.mark.parametrize("random",
521 [np.random, np.random.RandomState(), np.random.default_rng()])

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
reshapeMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected