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

Method test_masked_all_like

numpy/ma/tests/test_extras.py:127–145  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

125 assert_equal(masked_arr['b']._fill_value.shape, ())
126
127 def test_masked_all_like(self):
128 # Tests masked_all
129 # Standard dtype
130 base = array([1, 2], dtype=float)
131 test = masked_all_like(base)
132 control = array([1, 1], mask=[1, 1], dtype=float)
133 assert_equal(test, control)
134 # Flexible dtype
135 dt = np.dtype({'names': ['a', 'b'], 'formats': ['f', 'f']})
136 base = array([(0, 0), (0, 0)], mask=[(1, 1), (1, 1)], dtype=dt)
137 test = masked_all_like(base)
138 control = array([(10, 10), (10, 10)], mask=[(1, 1), (1, 1)], dtype=dt)
139 assert_equal(test, control)
140 # Nested dtype
141 dt = np.dtype([('a', 'f'), ('b', [('ba', 'f'), ('bb', 'f')])])
142 control = array([(1, (1, 1)), (1, (1, 1))],
143 mask=[(1, (1, 1)), (1, (1, 1))], dtype=dt)
144 test = masked_all_like(control)
145 assert_equal(test, control)
146
147 def check_clump(self, f):
148 for i in range(1, 7):

Callers

nothing calls this directly

Calls 4

arrayFunction · 0.90
masked_all_likeFunction · 0.90
assert_equalFunction · 0.90
dtypeMethod · 0.45

Tested by

no test coverage detected