MCPcopy
hub / github.com/numpy/numpy / test_ones

Method test_ones

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

Source from the content-addressed store, hash-verified

3550 assert_(np.may_share_memory(a.mask, b.mask))
3551
3552 def test_ones(self):
3553 # Tests ones/like
3554 datatype = [('a', int), ('b', float), ('c', '|S8')]
3555 a = masked_array([(1, 1.1, '1.1'), (2, 2.2, '2.2'), (3, 3.3, '3.3')],
3556 dtype=datatype)
3557 assert_equal(len(a.fill_value.item()), len(datatype))
3558
3559 b = ones(len(a), dtype=datatype)
3560 assert_equal(b.shape, a.shape)
3561 assert_equal(b.fill_value, a.fill_value)
3562
3563 b = ones_like(a)
3564 assert_equal(b.shape, a.shape)
3565 assert_equal(b.fill_value, a.fill_value)
3566
3567 # check ones_like mask handling
3568 a = masked_array([1, 2, 3], mask=[False, True, False])
3569 b = ones_like(a)
3570 assert_(not np.may_share_memory(a.mask, b.mask))
3571 b = a.view()
3572 assert_(np.may_share_memory(a.mask, b.mask))
3573
3574 @pytest.mark.filterwarnings(WARNING_MARK_SPEC)
3575 def test_put(self):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected