MCPcopy
hub / github.com/numpy/numpy / test_creation_maskcreation

Method test_creation_maskcreation

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

Source from the content-addressed store, hash-verified

293 assert_equal(xx.shape, xx._mask.shape)
294
295 def test_creation_maskcreation(self):
296 # Tests how masks are initialized at the creation of Maskedarrays.
297 data = arange(24, dtype=float)
298 data[[3, 6, 15]] = masked
299 dma_1 = MaskedArray(data)
300 assert_equal(dma_1.mask, data.mask)
301 dma_2 = MaskedArray(dma_1)
302 assert_equal(dma_2.mask, dma_1.mask)
303 dma_3 = MaskedArray(dma_1, mask=[1, 0, 0, 0] * 6)
304 fail_if_equal(dma_3.mask, dma_1.mask)
305
306 x = array([1, 2, 3], mask=True)
307 assert_equal(x._mask, [True, True, True])
308 x = array([1, 2, 3], mask=False)
309 assert_equal(x._mask, [False, False, False])
310 y = array([1, 2, 3], mask=x._mask, copy=False)
311 assert_(np.may_share_memory(x.mask, y.mask))
312 y = array([1, 2, 3], mask=x._mask, copy=True)
313 assert_(not np.may_share_memory(x.mask, y.mask))
314 x = array([1, 2, 3], mask=None)
315 assert_equal(x._mask, [False, False, False])
316
317 def test_masked_singleton_array_creation_warns(self):
318 # The first works, but should not (ideally), there may be no way

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected