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

Method test_squeeze

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

Source from the content-addressed store, hash-verified

3864 argsort(a, descending=True)
3865
3866 def test_squeeze(self):
3867 # Check squeeze
3868 data = masked_array([[1, 2, 3]])
3869 assert_equal(data.squeeze(), [1, 2, 3])
3870 data = masked_array([[1, 2, 3]], mask=[[1, 1, 1]])
3871 assert_equal(data.squeeze(), [1, 2, 3])
3872 assert_equal(data.squeeze()._mask, [1, 1, 1])
3873
3874 # normal ndarrays return a view
3875 arr = np.array([[1]])
3876 arr_sq = arr.squeeze()
3877 assert_equal(arr_sq, 1)
3878 arr_sq[...] = 2
3879 assert_equal(arr[0, 0], 2)
3880
3881 # so maskedarrays should too
3882 m_arr = masked_array([[1]], mask=True)
3883 m_arr_sq = m_arr.squeeze()
3884 assert_(m_arr_sq is not np.ma.masked)
3885 assert_equal(m_arr_sq.mask, True)
3886 m_arr_sq[...] = 2
3887 assert_equal(m_arr[0, 0], 2)
3888
3889 def test_swapaxes(self):
3890 # Tests swapaxes on MaskedArrays.

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
assert_Function · 0.85
squeezeMethod · 0.45

Tested by

no test coverage detected