summaryrefslogtreecommitdiff
path: root/numpy/lib/io.py
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2009-02-14 22:42:29 +0000
committerpierregm <pierregm@localhost>2009-02-14 22:42:29 +0000
commitb4b2d63b15f694ff9fc469f366af5b9a2e3653fc (patch)
tree177820b790222e983fa0672e6f5e071c011aac53 /numpy/lib/io.py
parentc1877cb6d2f56a817fcbc046820abcc338302d3f (diff)
downloadnumpy-b4b2d63b15f694ff9fc469f366af5b9a2e3653fc.tar.gz
* genfromtxt : fixed case when using explicit converters and explicit dtype.
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r--numpy/lib/io.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py
index 4ff2a3945..12765e17c 100644
--- a/numpy/lib/io.py
+++ b/numpy/lib/io.py
@@ -837,6 +837,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, skiprows=0,
missing_values = [_.missing_values for _ in converters]
# Update the converters to use the user-defined ones
+ uc_update = []
for (i, conv) in user_converters.iteritems():
# If the converter is specified by column names, use the index instead
if _is_string_like(i):
@@ -850,6 +851,9 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, skiprows=0,
converters[i].update(conv, default=None,
missing_values=missing_values[i],
locked=True)
+ uc_update.append((i, conv))
+ # Make sure we have the corrected keys in user_converters...
+ user_converters.update(uc_update)
# Reset the names to match the usecols
if (not first_line) and usecols:
@@ -960,8 +964,14 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, skiprows=0,
descr.append(('', ttype))
else:
descr.append(('', dtype))
+ # So we changed the dtype ?
if not ishomogeneous:
- dtype = np.dtype(descr)
+ # We have more than one field
+ if len(descr) > 1:
+ dtype = np.dtype(descr)
+ # We have only one field: drop the name if not needed.
+ else:
+ dtype = np.dtype(ttype)
#
output = np.array(data, dtype)
if usemask: