summaryrefslogtreecommitdiff
path: root/numpy/lib/_iotools.py
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2009-02-05 04:31:51 +0000
committerpierregm <pierregm@localhost>2009-02-05 04:31:51 +0000
commit911e94dd0a64adae9fb2057fb0210e512a9b7d4a (patch)
treec41d7f3027db2d581547f09168f2363cac618be9 /numpy/lib/_iotools.py
parent12750f7b0f6a5aa2cb318848de8e09076eb30fa2 (diff)
downloadnumpy-911e94dd0a64adae9fb2057fb0210e512a9b7d4a.tar.gz
* genfromtxt : Fixed when a dtype involving objects is explicitly given. Raise a NotImplementedError if the dtype is nested.
* _iotools : make sure StringConverter gets properly initiated when a function returning a np.object is used as input parameter.
Diffstat (limited to 'numpy/lib/_iotools.py')
-rw-r--r--numpy/lib/_iotools.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index 644d83d1c..23053bf4d 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -54,6 +54,16 @@ def _to_filehandle(fname, flag='r', return_opened=False):
return fhd
+def has_nested_fields(ndtype):
+ """
+ Returns whether one or several fields of a structured array are nested.
+ """
+ for name in ndtype.names or ():
+ if ndtype[name].names:
+ return True
+ return False
+
+
def flatten_dtype(ndtype):
"""
Unpack a structured data-type.
@@ -71,7 +81,6 @@ def flatten_dtype(ndtype):
return types
-
class LineSplitter:
"""
Defines a function to split a string at a given delimiter or at given places.
@@ -377,11 +386,17 @@ class StringConverter:
default = None
ttype = self._getsubdtype(default)
# Set the status according to the dtype
+ _status = -1
for (i, (deftype, func, default_def)) in enumerate(self._mapper):
if np.issubdtype(ttype, deftype):
- self._status = i
+ _status = i
self.default = default or default_def
break
+ if _status == -1:
+ # We never found a match in the _mapper...
+ _status = 0
+ self.default = default
+ self._status = _status
# If the input was a dtype, set the function to the last we saw
if self.func is None:
self.func = func