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

Method test_empty

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

Source from the content-addressed store, hash-verified

3292 assert_equal(b, [2, 3, 4])
3293
3294 def test_empty(self):
3295 # Tests empty/like
3296 datatype = [('a', int), ('b', float), ('c', '|S8')]
3297 a = masked_array([(1, 1.1, '1.1'), (2, 2.2, '2.2'), (3, 3.3, '3.3')],
3298 dtype=datatype)
3299 assert_equal(len(a.fill_value.item()), len(datatype))
3300
3301 b = empty_like(a)
3302 assert_equal(b.shape, a.shape)
3303 assert_equal(b.fill_value, a.fill_value)
3304
3305 b = empty(len(a), dtype=datatype)
3306 assert_equal(b.shape, a.shape)
3307 assert_equal(b.fill_value, a.fill_value)
3308
3309 # check empty_like mask handling
3310 a = masked_array([1, 2, 3], mask=[False, True, False])
3311 b = empty_like(a)
3312 assert_(not np.may_share_memory(a.mask, b.mask))
3313 b = a.view(masked_array)
3314 assert_(np.may_share_memory(a.mask, b.mask))
3315
3316 def test_zeros(self):
3317 # Tests zeros/like

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected