MCPcopy
hub / github.com/numpy/numpy / test_empty

Method test_empty

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

Source from the content-addressed store, hash-verified

3506 assert_equal(b, [2, 3, 4])
3507
3508 def test_empty(self):
3509 # Tests empty/like
3510 datatype = [('a', int), ('b', float), ('c', '|S8')]
3511 a = masked_array([(1, 1.1, '1.1'), (2, 2.2, '2.2'), (3, 3.3, '3.3')],
3512 dtype=datatype)
3513 assert_equal(len(a.fill_value.item()), len(datatype))
3514
3515 b = empty_like(a)
3516 assert_equal(b.shape, a.shape)
3517 assert_equal(b.fill_value, a.fill_value)
3518
3519 b = empty(len(a), dtype=datatype)
3520 assert_equal(b.shape, a.shape)
3521 assert_equal(b.fill_value, a.fill_value)
3522
3523 # check empty_like mask handling
3524 a = masked_array([1, 2, 3], mask=[False, True, False])
3525 b = empty_like(a)
3526 assert_(not np.may_share_memory(a.mask, b.mask))
3527 b = a.view(masked_array)
3528 assert_(np.may_share_memory(a.mask, b.mask))
3529
3530 def test_zeros(self):
3531 # Tests zeros/like

Callers

nothing calls this directly

Calls 6

assert_equalFunction · 0.90
empty_likeFunction · 0.90
emptyFunction · 0.85
assert_Function · 0.85
itemMethod · 0.80
viewMethod · 0.45

Tested by

no test coverage detected