MCPcopy Index your code
hub / github.com/numpy/numpy / test_shuffle_masked

Method test_shuffle_masked

numpy/random/tests/test_randomstate.py:714–730  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

712 assert_array_equal(actual, desired)
713
714 def test_shuffle_masked(self):
715 # gh-3263
716 a = np.ma.masked_values(np.reshape(range(20), (5, 4)) % 3 - 1, -1)
717 b = np.ma.masked_values(np.arange(20) % 3 - 1, -1)
718 a_orig = a.copy()
719 b_orig = b.copy()
720 for i in range(50):
721 random.shuffle(a)
722 assert_equal(
723 sorted(a.data[~a.mask]), sorted(a_orig.data[~a_orig.mask]))
724 random.shuffle(b)
725 assert_equal(
726 sorted(b.data[~b.mask]), sorted(b_orig.data[~b_orig.mask]))
727
728 def test_shuffle_invalid_objects(self):
729 x = np.array(3)
730 assert_raises(TypeError, random.shuffle, x)
731
732 def test_permutation(self):
733 rng = random.RandomState(self.seed)

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
reshapeMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected