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

Method test_take

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

Source from the content-addressed store, hash-verified

3910 assert_equal(mXXswapped.shape, (2, 2, 3, 3))
3911
3912 def test_take(self):
3913 # Tests take
3914 x = masked_array([10, 20, 30, 40], [0, 1, 0, 1])
3915 assert_equal(x.take([0, 0, 3]), masked_array([10, 10, 40], [0, 0, 1]))
3916 assert_equal(x.take([0, 0, 3]), x[[0, 0, 3]])
3917 assert_equal(x.take([[0, 1], [0, 1]]),
3918 masked_array([[10, 20], [10, 20]], [[0, 1], [0, 1]]))
3919
3920 # assert_equal crashes when passed np.ma.mask
3921 assert_(x[1] is np.ma.masked)
3922 assert_(x.take(1) is np.ma.masked)
3923
3924 x = array([[10, 20, 30], [40, 50, 60]], mask=[[0, 0, 1], [1, 0, 0, ]])
3925 assert_equal(x.take([0, 2], axis=1),
3926 array([[10, 30], [40, 60]], mask=[[0, 1], [1, 0]]))
3927 assert_equal(take(x, [0, 2], axis=1),
3928 array([[10, 30], [40, 60]], mask=[[0, 1], [1, 0]]))
3929
3930 def test_take_masked_indices(self):
3931 # Test take w/ masked indices

Callers

nothing calls this directly

Calls 5

assert_equalFunction · 0.90
arrayFunction · 0.90
takeFunction · 0.90
assert_Function · 0.85
takeMethod · 0.80

Tested by

no test coverage detected