diff options
Diffstat (limited to 'numpy/lib/tests/test_regression.py')
-rw-r--r-- | numpy/lib/tests/test_regression.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py index c0cfff9a5..c244aea87 100644 --- a/numpy/lib/tests/test_regression.py +++ b/numpy/lib/tests/test_regression.py @@ -202,5 +202,25 @@ class TestRegression(TestCase): except: raise AssertionError() + def test_loadtxt_fields_subarrays(self): + # For ticket #1936 + from StringIO import StringIO + dt = [("a", 'u1', 2), ("b", 'u1', 2)] + x = np.loadtxt(StringIO("0 1 2 3"), dtype=dt) + assert_equal(x, np.array([((0, 1), (2, 3))], dtype=dt)) + + dt = [("a", [("a", 'u1', (1,3)), ("b", 'u1')])] + x = np.loadtxt(StringIO("0 1 2 3"), dtype=dt) + assert_equal(x, np.array([(((0,1,2), 3),)], dtype=dt)) + + dt = [("a", 'u1', (2,2))] + x = np.loadtxt(StringIO("0 1 2 3"), dtype=dt) + assert_equal(x, np.array([(((0, 1), (2, 3)),)], dtype=dt)) + + dt = [("a", 'u1', (2,3,2))] + x = np.loadtxt(StringIO("0 1 2 3 4 5 6 7 8 9 10 11"), dtype=dt) + data = [((((0,1), (2,3), (4,5)), ((6,7), (8,9), (10,11))),)] + assert_equal(x, np.array(data, dtype=dt)) + if __name__ == "__main__": run_module_suite() |