summaryrefslogtreecommitdiff
path: root/numpy/lib/io.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2009-05-27 23:27:19 +0000
committerStefan van der Walt <stefan@sun.ac.za>2009-05-27 23:27:19 +0000
commita2bf56aaf98ea150079ee5d05da21b18de68252a (patch)
treebbf02c6c62a98cfd74906564cb45843130258a1b /numpy/lib/io.py
parent81a26d7fea2f4bf913426ec587ed211bf7c33fe5 (diff)
downloadnumpy-a2bf56aaf98ea150079ee5d05da21b18de68252a.tar.gz
loadtxt: allow shaped dtypes.
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r--numpy/lib/io.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py
index cfcced55e..03274845c 100644
--- a/numpy/lib/io.py
+++ b/numpy/lib/io.py
@@ -424,7 +424,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters=None,
def flatten_dtype(dt):
"""Unpack a structured data-type."""
if dt.names is None:
- return [dt]
+ # If the dtype is flattened, return.
+ # If the dtype has a shape, the dtype occurs
+ # in the list more than once.
+ return [dt.base] * int(np.prod(dt.shape))
else:
types = []
for field in dt.names: