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

Method test_shuffle

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

Source from the content-addressed store, hash-verified

485 assert_equal(actual, desired)
486
487 def test_shuffle(self):
488 # Test lists, arrays (of various dtypes), and multidimensional versions
489 # of both, c-contiguous or not:
490 for conv in [lambda x: np.array([]),
491 lambda x: x,
492 lambda x: np.asarray(x).astype(np.int8),
493 lambda x: np.asarray(x).astype(np.float32),
494 lambda x: np.asarray(x).astype(np.complex64),
495 lambda x: np.asarray(x).astype(object),
496 lambda x: [(i, i) for i in x],
497 lambda x: np.asarray([[i, i] for i in x]),
498 lambda x: np.vstack([x, x]).T,
499 # gh-11442
500 lambda x: (np.asarray([(i, i) for i in x],
501 [("a", int), ("b", int)])
502 .view(np.recarray)),
503 # gh-4270
504 lambda x: np.asarray([(i, i) for i in x],
505 [("a", object), ("b", np.int32)])]:
506 rng = random.RandomState(self.seed)
507 alist = conv([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
508 rng.shuffle(alist)
509 actual = alist
510 desired = conv([0, 1, 9, 6, 2, 4, 5, 8, 7, 3])
511 assert_array_equal(actual, desired)
512
513 def test_shuffle_masked(self):
514 # 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