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

Method test_mask_or

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

Source from the content-addressed store, hash-verified

4812 assert_(res is nomask, msgformat % (cpy, shr, dt))
4813
4814 def test_mask_or(self):
4815 # Initialize
4816 mtype = [('a', bool), ('b', bool)]
4817 mask = np.array([(0, 0), (0, 1), (1, 0), (0, 0)], dtype=mtype)
4818 # Test using nomask as input
4819 test = mask_or(mask, nomask)
4820 assert_equal(test, mask)
4821 test = mask_or(nomask, mask)
4822 assert_equal(test, mask)
4823 # Using False as input
4824 test = mask_or(mask, False)
4825 assert_equal(test, mask)
4826 # Using another array w / the same dtype
4827 other = np.array([(0, 1), (0, 1), (0, 1), (0, 1)], dtype=mtype)
4828 test = mask_or(mask, other)
4829 control = np.array([(0, 1), (0, 1), (1, 1), (0, 1)], dtype=mtype)
4830 assert_equal(test, control)
4831 # Using another array w / a different dtype
4832 othertype = [('A', bool), ('B', bool)]
4833 other = np.array([(0, 1), (0, 1), (0, 1), (0, 1)], dtype=othertype)
4834 try:
4835 test = mask_or(mask, other)
4836 except ValueError:
4837 pass
4838 # Using nested arrays
4839 dtype = [('a', bool), ('b', [('ba', bool), ('bb', bool)])]
4840 amask = np.array([(0, (1, 0)), (0, (1, 0))], dtype=dtype)
4841 bmask = np.array([(1, (0, 1)), (0, (0, 0))], dtype=dtype)
4842 cntrl = np.array([(1, (1, 1)), (0, (1, 0))], dtype=dtype)
4843 assert_equal(mask_or(amask, bmask), cntrl)
4844
4845 def test_flatten_mask(self):
4846 # Tests flatten mask

Callers

nothing calls this directly

Calls 2

mask_orFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected