MCPcopy
hub / github.com/numpy/numpy / test_shuffle

Method test_shuffle

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

Source from the content-addressed store, hash-verified

685 assert_equal(actual, desired)
686
687 def test_shuffle(self):
688 # Test lists, arrays (of various dtypes), and multidimensional versions
689 # of both, c-contiguous or not:
690 for conv in [lambda x: np.array([]),
691 lambda x: x,
692 lambda x: np.asarray(x).astype(np.int8),
693 lambda x: np.asarray(x).astype(np.float32),
694 lambda x: np.asarray(x).astype(np.complex64),
695 lambda x: np.asarray(x).astype(object),
696 lambda x: [(i, i) for i in x],
697 lambda x: np.asarray([[i, i] for i in x]),
698 lambda x: np.vstack([x, x]).T,
699 # gh-11442
700 lambda x: (np.asarray([(i, i) for i in x],
701 [("a", int), ("b", int)])
702 .view(np.recarray)),
703 # gh-4270
704 lambda x: np.asarray([(i, i) for i in x],
705 [("a", object, (1,)),
706 ("b", np.int32, (1,))])]:
707 rng = random.RandomState(self.seed)
708 alist = conv([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
709 rng.shuffle(alist)
710 actual = alist
711 desired = conv([0, 1, 9, 6, 2, 4, 5, 8, 7, 3])
712 assert_array_equal(actual, desired)
713
714 def test_shuffle_masked(self):
715 # gh-3263

Callers

nothing calls this directly

Calls 4

assert_array_equalFunction · 0.90
astypeMethod · 0.80
convFunction · 0.50
viewMethod · 0.45

Tested by

no test coverage detected