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

Method test_basic

numpy/lib/tests/test_shape_base.py:628–643  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

626
627class TestSqueeze:
628 def test_basic(self):
629 from numpy.random import rand
630
631 a = rand(20, 10, 10, 1, 1)
632 b = rand(20, 1, 10, 1, 20)
633 c = rand(1, 1, 20, 10)
634 assert_array_equal(np.squeeze(a), np.reshape(a, (20, 10, 10)))
635 assert_array_equal(np.squeeze(b), np.reshape(b, (20, 10, 20)))
636 assert_array_equal(np.squeeze(c), np.reshape(c, (20, 10)))
637
638 # Squeezing to 0-dim should still give an ndarray
639 a = [[[1.5]]]
640 res = np.squeeze(a)
641 assert_equal(res, 1.5)
642 assert_equal(res.ndim, 0)
643 assert_equal(type(res), np.ndarray)
644
645
646class TestKron:

Callers

nothing calls this directly

Calls 5

assert_array_equalFunction · 0.90
assert_equalFunction · 0.90
randFunction · 0.85
reshapeMethod · 0.80
squeezeMethod · 0.45

Tested by

no test coverage detected