diff options
author | pierregm <pierregm@localhost> | 2009-01-26 21:04:26 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2009-01-26 21:04:26 +0000 |
commit | 2e346ec1e1000c11f484708e2997b7b95808a00d (patch) | |
tree | ed452e940d6c9f7e00976604acd887bdfb529d70 /numpy/lib/_iotools.py | |
parent | 9ac9630d805fd4ec235e009782f019fa8d8e8fa9 (diff) | |
download | numpy-2e346ec1e1000c11f484708e2997b7b95808a00d.tar.gz |
* _iotools.StringConverter :
- add a _checked attribute to indicate whether the converter has been upgraded or not.
- switched the default value for bool to False
* io.genfromtxt:
- fixed for the case where a whole column is masked: switch to bool or the common dtype (if needed)
Diffstat (limited to 'numpy/lib/_iotools.py')
-rw-r--r-- | numpy/lib/_iotools.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index 3f3c6655e..595c01d29 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -294,7 +294,7 @@ class StringConverter: """ # - _mapper = [(nx.bool_, str2bool, None), + _mapper = [(nx.bool_, str2bool, False), (nx.integer, int, -1), (nx.floating, float, nx.nan), (complex, complex, nx.nan+0j), @@ -354,7 +354,7 @@ class StringConverter: if dtype_or_func is None: self.func = str2bool self._status = 0 - self.default = default + self.default = default or False ttype = np.bool else: # Is the input a np.dtype ? @@ -396,6 +396,7 @@ class StringConverter: # self._callingfunction = self._strict_call self.type = ttype + self._checked = False # def _loose_call(self, value): try: @@ -408,6 +409,8 @@ class StringConverter: return self.func(value) except ValueError: if value.strip() in self.missing_values: + if not self._status: + self._checked = False return self.default raise ValueError("Cannot convert string '%s'" % value) # @@ -421,6 +424,7 @@ class StringConverter: The order in which the converters are tested is read from the :attr:`_status` attribute of the instance. """ + self._checked = True try: self._strict_call(value) except ValueError: |