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

Method test_shuffle_masked

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

Source from the content-addressed store, hash-verified

705 assert_array_equal(actual, desired)
706
707 def test_shuffle_masked(self):
708 # gh-3263
709 a = np.ma.masked_values(np.reshape(range(20), (5, 4)) % 3 - 1, -1)
710 b = np.ma.masked_values(np.arange(20) % 3 - 1, -1)
711 a_orig = a.copy()
712 b_orig = b.copy()
713 for i in range(50):
714 random.shuffle(a)
715 assert_equal(
716 sorted(a.data[~a.mask]), sorted(a_orig.data[~a_orig.mask]))
717 random.shuffle(b)
718 assert_equal(
719 sorted(b.data[~b.mask]), sorted(b_orig.data[~b_orig.mask]))
720
721 def test_shuffle_invalid_objects(self):
722 x = np.array(3)
723 assert_raises(TypeError, random.shuffle, x)
724
725 def test_permutation(self):
726 random.seed(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