summaryrefslogtreecommitdiff
path: root/numpy/lib/_iotools.py
diff options
context:
space:
mode:
authorpierregm <pierregmcode@gmail.com>2010-11-13 19:45:37 +0100
committerpierregm <pierregmcode@gmail.com>2010-11-13 21:19:51 +0100
commitde4de92be21e4dda3665648ad5102b3729d4e0b0 (patch)
tree574b81210ef3916b9a4ebf335e6e9b15dfde0fea /numpy/lib/_iotools.py
parentfad376ead11b8e0f3101d37b62b0c8d5ba40af72 (diff)
downloadnumpy-de4de92be21e4dda3665648ad5102b3729d4e0b0.tar.gz
genfromtxt: Taking more adequate testing values when updating converters: bug #1665
Diffstat (limited to 'numpy/lib/_iotools.py')
-rw-r--r--numpy/lib/_iotools.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index 8a0697d58..e24583ec1 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -707,8 +707,8 @@ class StringConverter:
self._status = _status
self.iterupgrade(value)
- def update(self, func, default=None, missing_values=asbytes(''),
- locked=False):
+ def update(self, func, default=None, testing_value=None,
+ missing_values=asbytes(''), locked=False):
"""
Set StringConverter attributes directly.
@@ -720,6 +720,9 @@ class StringConverter:
Value to return by default, that is, when the string to be converted
is flagged as missing. If not given, `StringConverter` tries to supply
a reasonable default value.
+ testing_value : str, optional
+ A string representing a standard input value of the converter.
+ This string is used to help defining a reasonable default value.
missing_values : sequence of str, optional
Sequence of strings indicating a missing value.
locked : bool, optional
@@ -741,7 +744,7 @@ class StringConverter:
self.type = self._getsubdtype(default)
else:
try:
- tester = func(asbytes('1'))
+ tester = func(testing_value or asbytes('1'))
except (TypeError, ValueError):
tester = None
self.type = self._getsubdtype(tester)