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

Method test_toflex

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

Source from the content-addressed store, hash-verified

3770 assert_(not isinstance(item, np.generic))
3771
3772 def test_toflex(self):
3773 # Test the conversion to records
3774 data = arange(10)
3775 record = data.toflex()
3776 assert_equal(record['_data'], data._data)
3777 assert_equal(record['_mask'], data._mask)
3778
3779 data[[0, 1, 2, -1]] = masked
3780 record = data.toflex()
3781 assert_equal(record['_data'], data._data)
3782 assert_equal(record['_mask'], data._mask)
3783
3784 ndtype = [('i', int), ('s', '|S3'), ('f', float)]
3785 data = array([(i, s, f) for (i, s, f) in zip(np.arange(10),
3786 'ABCDEFGHIJKLM',
3787 np.random.rand(10))],
3788 dtype=ndtype)
3789 data[[0, 1, 2, -1]] = masked
3790 record = data.toflex()
3791 assert_equal(record['_data'], data._data)
3792 assert_equal(record['_mask'], data._mask)
3793
3794 ndtype = np.dtype("int, (2,3)float, float")
3795 data = array([(i, f, ff) for (i, f, ff) in zip(np.arange(10),
3796 np.random.rand(10),
3797 np.random.rand(10))],
3798 dtype=ndtype)
3799 data[[0, 1, 2, -1]] = masked
3800 record = data.toflex()
3801 assert_equal_records(record['_data'], data._data)
3802 assert_equal_records(record['_mask'], data._mask)
3803
3804 def test_fromflex(self):
3805 # Test the reconstruction of a masked_array from a record

Callers

nothing calls this directly

Calls 6

assert_equalFunction · 0.90
arrayFunction · 0.90
assert_equal_recordsFunction · 0.90
arangeFunction · 0.85
toflexMethod · 0.80
dtypeMethod · 0.45

Tested by

no test coverage detected