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

Method test_take

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

Source from the content-addressed store, hash-verified

3672 assert_equal(mXXswapped.shape, (2, 2, 3, 3))
3673
3674 def test_take(self):
3675 # Tests take
3676 x = masked_array([10, 20, 30, 40], [0, 1, 0, 1])
3677 assert_equal(x.take([0, 0, 3]), masked_array([10, 10, 40], [0, 0, 1]))
3678 assert_equal(x.take([0, 0, 3]), x[[0, 0, 3]])
3679 assert_equal(x.take([[0, 1], [0, 1]]),
3680 masked_array([[10, 20], [10, 20]], [[0, 1], [0, 1]]))
3681
3682 # assert_equal crashes when passed np.ma.mask
3683 assert_(x[1] is np.ma.masked)
3684 assert_(x.take(1) is np.ma.masked)
3685
3686 x = array([[10, 20, 30], [40, 50, 60]], mask=[[0, 0, 1], [1, 0, 0, ]])
3687 assert_equal(x.take([0, 2], axis=1),
3688 array([[10, 30], [40, 60]], mask=[[0, 1], [1, 0]]))
3689 assert_equal(take(x, [0, 2], axis=1),
3690 array([[10, 30], [40, 60]], mask=[[0, 1], [1, 0]]))
3691
3692 def test_take_masked_indices(self):
3693 # Test take w/ masked indices

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected