MCPcopy Index your code
hub / github.com/numpy/numpy / test_toflex

Method test_toflex

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

Source from the content-addressed store, hash-verified

4008 assert_(not isinstance(item, np.generic))
4009
4010 def test_toflex(self):
4011 # Test the conversion to records
4012 data = arange(10)
4013 record = data.toflex()
4014 assert_equal(record['_data'], data._data)
4015 assert_equal(record['_mask'], data._mask)
4016
4017 data[[0, 1, 2, -1]] = masked
4018 record = data.toflex()
4019 assert_equal(record['_data'], data._data)
4020 assert_equal(record['_mask'], data._mask)
4021
4022 ndtype = [('i', int), ('s', '|S3'), ('f', float)]
4023 data = array(list(zip(np.arange(10),
4024 'ABCDEFGHIJKLM',
4025 np.random.rand(10))),
4026 dtype=ndtype)
4027 data[[0, 1, 2, -1]] = masked
4028 record = data.toflex()
4029 assert_equal(record['_data'], data._data)
4030 assert_equal(record['_mask'], data._mask)
4031
4032 ndtype = np.dtype("int, (2,3)float, float")
4033 data = array(list(zip(np.arange(10),
4034 np.random.rand(10),
4035 np.random.rand(10))),
4036 dtype=ndtype)
4037 data[[0, 1, 2, -1]] = masked
4038 record = data.toflex()
4039 assert_equal_records(record['_data'], data._data)
4040 assert_equal_records(record['_mask'], data._mask)
4041
4042 def test_fromflex(self):
4043 # Test the reconstruction of a masked_array from a record

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected