summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_regression.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2011-08-20 10:15:17 -0600
committerCharles Harris <charlesr.harris@gmail.com>2011-08-20 10:15:17 -0600
commitcdf1ff1d2f92582d5aa150573a056462341d2dcf (patch)
treeefa4aa266faf80b4ec040058416f7c3fd4b5882b /numpy/lib/tests/test_regression.py
parent9aac3a509e944104a28798563a2ba2d5eeb12964 (diff)
parenta54a0bdc89dd82ca3cfee89ae70a7fe3ee00e2a2 (diff)
downloadnumpy-cdf1ff1d2f92582d5aa150573a056462341d2dcf.tar.gz
Merge branch 'pull-140'
* pull-140: BUG: loadtxt: There was some extra nesting for subarray dtypes (Ticket #1936)
Diffstat (limited to 'numpy/lib/tests/test_regression.py')
-rw-r--r--numpy/lib/tests/test_regression.py20
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()