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

Method test_zeros

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

Source from the content-addressed store, hash-verified

3314 assert_(np.may_share_memory(a.mask, b.mask))
3315
3316 def test_zeros(self):
3317 # Tests zeros/like
3318 datatype = [('a', int), ('b', float), ('c', '|S8')]
3319 a = masked_array([(1, 1.1, '1.1'), (2, 2.2, '2.2'), (3, 3.3, '3.3')],
3320 dtype=datatype)
3321 assert_equal(len(a.fill_value.item()), len(datatype))
3322
3323 b = zeros(len(a), dtype=datatype)
3324 assert_equal(b.shape, a.shape)
3325 assert_equal(b.fill_value, a.fill_value)
3326
3327 b = zeros_like(a)
3328 assert_equal(b.shape, a.shape)
3329 assert_equal(b.fill_value, a.fill_value)
3330
3331 # check zeros_like mask handling
3332 a = masked_array([1, 2, 3], mask=[False, True, False])
3333 b = zeros_like(a)
3334 assert_(not np.may_share_memory(a.mask, b.mask))
3335 b = a.view()
3336 assert_(np.may_share_memory(a.mask, b.mask))
3337
3338 def test_ones(self):
3339 # Tests ones/like

Callers

nothing calls this directly

Calls 6

assert_equalFunction · 0.90
zeros_likeFunction · 0.90
itemMethod · 0.80
zerosFunction · 0.50
assert_Function · 0.50
viewMethod · 0.45

Tested by

no test coverage detected