summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_regression.py
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-08-18 20:37:36 -0700
committerCharles Harris <charlesr.harris@gmail.com>2011-08-20 10:09:33 -0600
commita54a0bdc89dd82ca3cfee89ae70a7fe3ee00e2a2 (patch)
tree563dec10e782285ee72b79ba82a330e75b7e1063 /numpy/lib/tests/test_regression.py
parent78f7542add429689465c79d2d2f2042c38239672 (diff)
downloadnumpy-a54a0bdc89dd82ca3cfee89ae70a7fe3ee00e2a2.tar.gz
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()