summaryrefslogtreecommitdiff
path: root/numpy/lib/_iotools.py
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2009-10-12 04:45:31 +0000
committerpierregm <pierregm@localhost>2009-10-12 04:45:31 +0000
commit80851e34d2955a331cecb9f50d2287d33618dd3e (patch)
treea1c2ea17ef9f9192b1ad7839c31d7f73bc579bfe /numpy/lib/_iotools.py
parent295e24af415bb49f12a632f0e27fb9e2a1099ea2 (diff)
downloadnumpy-80851e34d2955a331cecb9f50d2287d33618dd3e.tar.gz
* _iotools.StringConverter
- prevents an explicit default to be overwritten during upgrade * io.genfromtxt - deprecate `skiprows` for `skip_header` - deprecate `missing` for `missing_values` - `missing_values` can now be a sequence - add support for `filling_values` * fixed ticket #1257
Diffstat (limited to 'numpy/lib/_iotools.py')
-rw-r--r--numpy/lib/_iotools.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index 9e8bcce2a..398ed07a4 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -557,6 +557,7 @@ class StringConverter:
self._callingfunction = self._strict_call
self.type = ttype
self._checked = False
+ self._initial_default = default
#
def _loose_call(self, value):
try:
@@ -608,12 +609,18 @@ class StringConverter:
raise ConverterLockError(errmsg)
_statusmax = len(self._mapper)
# Complains if we try to upgrade by the maximum
- if self._status == _statusmax:
+ _status = self._status
+ if _status == _statusmax:
errmsg = "Could not find a valid conversion function"
raise ConverterError(errmsg)
- elif self._status < _statusmax - 1:
- self._status += 1
- (self.type, self.func, self.default) = self._mapper[self._status]
+ elif _status < _statusmax - 1:
+ _status += 1
+ (self.type, self.func, default) = self._mapper[_status]
+ self._status = _status
+ if self._initial_default is not None:
+ self.default = self._initial_default
+ else:
+ self.default = default
self.upgrade(value)
def iterupgrade(self, value):
@@ -630,11 +637,17 @@ class StringConverter:
raise ConverterLockError(errmsg)
_statusmax = len(self._mapper)
# Complains if we try to upgrade by the maximum
- if self._status == _statusmax:
+ _status = self._status
+ if _status == _statusmax:
raise ConverterError("Could not find a valid conversion function")
- elif self._status < _statusmax - 1:
- self._status += 1
- (self.type, self.func, self.default) = self._mapper[self._status]
+ elif _status < _statusmax - 1:
+ _status += 1
+ (self.type, self.func, default) = self._mapper[_status]
+ if self._initial_default is not None:
+ self.default = self._initial_default
+ else:
+ self.default = default
+ self._status = _status
self.iterupgrade(value)
def update(self, func, default=None, missing_values='', locked=False):