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

Method test_mask_or

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

Source from the content-addressed store, hash-verified

5039 assert_(res is nomask, msgformat % (cpy, shr, dtype))
5040
5041 def test_mask_or(self):
5042 # Initialize
5043 mtype = [('a', bool), ('b', bool)]
5044 mask = np.array([(0, 0), (0, 1), (1, 0), (0, 0)], dtype=mtype)
5045 # Test using nomask as input
5046 test = mask_or(mask, nomask)
5047 assert_equal(test, mask)
5048 test = mask_or(nomask, mask)
5049 assert_equal(test, mask)
5050 # Using False as input
5051 test = mask_or(mask, False)
5052 assert_equal(test, mask)
5053 # Using another array w / the same dtype
5054 other = np.array([(0, 1), (0, 1), (0, 1), (0, 1)], dtype=mtype)
5055 test = mask_or(mask, other)
5056 control = np.array([(0, 1), (0, 1), (1, 1), (0, 1)], dtype=mtype)
5057 assert_equal(test, control)
5058 # Using another array w / a different dtype
5059 othertype = [('A', bool), ('B', bool)]
5060 other = np.array([(0, 1), (0, 1), (0, 1), (0, 1)], dtype=othertype)
5061 try:
5062 test = mask_or(mask, other)
5063 except ValueError:
5064 pass
5065 # Using nested arrays
5066 dtype = [('a', bool), ('b', [('ba', bool), ('bb', bool)])]
5067 amask = np.array([(0, (1, 0)), (0, (1, 0))], dtype=dtype)
5068 bmask = np.array([(1, (0, 1)), (0, (0, 0))], dtype=dtype)
5069 cntrl = np.array([(1, (1, 1)), (0, (1, 0))], dtype=dtype)
5070 assert_equal(mask_or(amask, bmask), cntrl)
5071
5072 a = np.array([False, False])
5073 assert mask_or(a, a) is nomask # gh-27360
5074
5075 def test_allequal(self):
5076 x = array([1, 2, 3], mask=[0, 0, 0])

Callers

nothing calls this directly

Calls 2

mask_orFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected