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

Method test_squeeze

numpy/ma/tests/test_core.py:3628–3649  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3626 assert_equal(np.argsort(a), argsort(a))
3627
3628 def test_squeeze(self):
3629 # Check squeeze
3630 data = masked_array([[1, 2, 3]])
3631 assert_equal(data.squeeze(), [1, 2, 3])
3632 data = masked_array([[1, 2, 3]], mask=[[1, 1, 1]])
3633 assert_equal(data.squeeze(), [1, 2, 3])
3634 assert_equal(data.squeeze()._mask, [1, 1, 1])
3635
3636 # normal ndarrays return a view
3637 arr = np.array([[1]])
3638 arr_sq = arr.squeeze()
3639 assert_equal(arr_sq, 1)
3640 arr_sq[...] = 2
3641 assert_equal(arr[0,0], 2)
3642
3643 # so maskedarrays should too
3644 m_arr = masked_array([[1]], mask=True)
3645 m_arr_sq = m_arr.squeeze()
3646 assert_(m_arr_sq is not np.ma.masked)
3647 assert_equal(m_arr_sq.mask, True)
3648 m_arr_sq[...] = 2
3649 assert_equal(m_arr[0,0], 2)
3650
3651 def test_swapaxes(self):
3652 # Tests swapaxes on MaskedArrays.

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
assert_Function · 0.50
squeezeMethod · 0.45

Tested by

no test coverage detected