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

Method test_take_masked_indices

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

Source from the content-addressed store, hash-verified

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
3932 a = np.array((40, 18, 37, 9, 22))
3933 indices = np.arange(3)[None, :] + np.arange(5)[:, None]
3934 mindices = array(indices, mask=(indices >= len(a)))
3935 # No mask
3936 test = take(a, mindices, mode='clip')
3937 ctrl = array([[40, 18, 37],
3938 [18, 37, 9],
3939 [37, 9, 22],
3940 [9, 22, 22],
3941 [22, 22, 22]])
3942 assert_equal(test, ctrl)
3943 # Masked indices
3944 test = take(a, mindices)
3945 ctrl = array([[40, 18, 37],
3946 [18, 37, 9],
3947 [37, 9, 22],
3948 [9, 22, 40],
3949 [22, 40, 40]])
3950 ctrl[3, 2] = ctrl[4, 1] = ctrl[4, 2] = masked
3951 assert_equal(test, ctrl)
3952 assert_equal(test.mask, ctrl.mask)
3953 # Masked input + masked indices
3954 a = array((40, 18, 37, 9, 22), mask=(0, 1, 0, 0, 0))
3955 test = take(a, mindices)
3956 ctrl[0, 1] = ctrl[1, 0] = masked
3957 assert_equal(test, ctrl)
3958 assert_equal(test.mask, ctrl.mask)
3959
3960 def test_tolist(self):
3961 # Tests to list

Callers

nothing calls this directly

Calls 3

arrayFunction · 0.90
takeFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected