diff options
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r-- | numpy/lib/tests/test_io.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 6458d8916..5eb1394e4 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -2,7 +2,7 @@ import numpy as np import numpy.ma as ma from numpy.ma.testutils import (TestCase, assert_equal, assert_array_equal, assert_raises, run_module_suite) -from numpy.testing import assert_warns +from numpy.testing import assert_warns, assert_ import sys @@ -452,6 +452,17 @@ class TestLoadTxt(TestCase): finally: os.unlink(name) + def test_structure_unpack(self): + txt = StringIO(asbytes("M 21 72\nF 35 58")) + dt = { 'names': ('a', 'b', 'c'), 'formats': ('|S1', '<i4', '<f4')} + a, b, c = np.loadtxt(txt, dtype=dt, unpack=True) + assert_(a.dtype.str == '|S1') + assert_(b.dtype.str == '<i4') + assert_(c.dtype.str == '<f4') + assert_array_equal(a, np.array(['M', 'F'])) + assert_array_equal(b, np.array([21, 35])) + assert_array_equal(c, np.array([ 72., 58.])) + class Testfromregex(TestCase): def test_record(self): |