From 2e346ec1e1000c11f484708e2997b7b95808a00d Mon Sep 17 00:00:00 2001 From: pierregm Date: Mon, 26 Jan 2009 21:04:26 +0000 Subject: * _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) --- numpy/lib/_iotools.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'numpy/lib/_iotools.py') 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: -- cgit v1.2.1