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

Method test_creation_maskcreation

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

Source from the content-addressed store, hash-verified

198 assert_equal(xx.shape, xx._mask.shape)
199
200 def test_creation_maskcreation(self):
201 # Tests how masks are initialized at the creation of Maskedarrays.
202 data = arange(24, dtype=float)
203 data[[3, 6, 15]] = masked
204 dma_1 = MaskedArray(data)
205 assert_equal(dma_1.mask, data.mask)
206 dma_2 = MaskedArray(dma_1)
207 assert_equal(dma_2.mask, dma_1.mask)
208 dma_3 = MaskedArray(dma_1, mask=[1, 0, 0, 0] * 6)
209 fail_if_equal(dma_3.mask, dma_1.mask)
210
211 x = array([1, 2, 3], mask=True)
212 assert_equal(x._mask, [True, True, True])
213 x = array([1, 2, 3], mask=False)
214 assert_equal(x._mask, [False, False, False])
215 y = array([1, 2, 3], mask=x._mask, copy=False)
216 assert_(np.may_share_memory(x.mask, y.mask))
217 y = array([1, 2, 3], mask=x._mask, copy=True)
218 assert_(not np.may_share_memory(x.mask, y.mask))
219 x = array([1, 2, 3], mask=None)
220 assert_equal(x._mask, [False, False, False])
221
222 def test_masked_singleton_array_creation_warns(self):
223 # The first works, but should not (ideally), there may be no way

Callers

nothing calls this directly

Calls 6

MaskedArrayClass · 0.90
assert_equalFunction · 0.90
fail_if_equalFunction · 0.90
arrayFunction · 0.90
arangeFunction · 0.85
assert_Function · 0.50

Tested by

no test coverage detected