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

Method test_basic

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

Source from the content-addressed store, hash-verified

655
656class TestSqueeze:
657 def test_basic(self):
658 from numpy.random import rand
659
660 a = rand(20, 10, 10, 1, 1)
661 b = rand(20, 1, 10, 1, 20)
662 c = rand(1, 1, 20, 10)
663 assert_array_equal(np.squeeze(a), np.reshape(a, (20, 10, 10)))
664 assert_array_equal(np.squeeze(b), np.reshape(b, (20, 10, 20)))
665 assert_array_equal(np.squeeze(c), np.reshape(c, (20, 10)))
666
667 # Squeezing to 0-dim should still give an ndarray
668 a = [[[1.5]]]
669 res = np.squeeze(a)
670 assert_equal(res, 1.5)
671 assert_equal(res.ndim, 0)
672 assert_equal(type(res), np.ndarray)
673
674
675class 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