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

Method test_ones

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

Source from the content-addressed store, hash-verified

3336 assert_(np.may_share_memory(a.mask, b.mask))
3337
3338 def test_ones(self):
3339 # Tests ones/like
3340 datatype = [('a', int), ('b', float), ('c', '|S8')]
3341 a = masked_array([(1, 1.1, '1.1'), (2, 2.2, '2.2'), (3, 3.3, '3.3')],
3342 dtype=datatype)
3343 assert_equal(len(a.fill_value.item()), len(datatype))
3344
3345 b = ones(len(a), dtype=datatype)
3346 assert_equal(b.shape, a.shape)
3347 assert_equal(b.fill_value, a.fill_value)
3348
3349 b = ones_like(a)
3350 assert_equal(b.shape, a.shape)
3351 assert_equal(b.fill_value, a.fill_value)
3352
3353 # check ones_like mask handling
3354 a = masked_array([1, 2, 3], mask=[False, True, False])
3355 b = ones_like(a)
3356 assert_(not np.may_share_memory(a.mask, b.mask))
3357 b = a.view()
3358 assert_(np.may_share_memory(a.mask, b.mask))
3359
3360 @suppress_copy_mask_on_assignment
3361 def test_put(self):

Callers

nothing calls this directly

Calls 6

assert_equalFunction · 0.90
onesFunction · 0.90
ones_likeFunction · 0.90
itemMethod · 0.80
assert_Function · 0.50
viewMethod · 0.45

Tested by

no test coverage detected