From a2bf56aaf98ea150079ee5d05da21b18de68252a Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 27 May 2009 23:27:19 +0000 Subject: loadtxt: allow shaped dtypes. --- numpy/lib/io.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'numpy/lib/io.py') 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: -- cgit v1.2.1