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

Method test_record

numpy/lib/tests/test_io.py:740–756  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

738 _npyio_impl._loadtxt_chunksize = self.orig_chunk
739
740 def test_record(self):
741 c = TextIO()
742 c.write('1 2\n3 4')
743 c.seek(0)
744 x = np.loadtxt(c, dtype=[('x', np.int32), ('y', np.int32)])
745 a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
746 assert_array_equal(x, a)
747
748 d = TextIO()
749 d.write('M 64 75.0\nF 25 60.0')
750 d.seek(0)
751 mydescriptor = {'names': ('gender', 'age', 'weight'),
752 'formats': ('S1', 'i4', 'f4')}
753 b = np.array([('M', 64.0, 75.0),
754 ('F', 25.0, 60.0)], dtype=mydescriptor)
755 y = np.loadtxt(d, dtype=mydescriptor)
756 assert_array_equal(y, b)
757
758 def test_array(self):
759 c = TextIO()

Callers

nothing calls this directly

Calls 4

writeMethod · 0.95
assert_array_equalFunction · 0.90
TextIOClass · 0.85
seekMethod · 0.80

Tested by

no test coverage detected