diff options
author | pierregm <pierregmcode@gmail.com> | 2010-11-13 19:45:37 +0100 |
---|---|---|
committer | pierregm <pierregmcode@gmail.com> | 2010-11-13 21:19:51 +0100 |
commit | de4de92be21e4dda3665648ad5102b3729d4e0b0 (patch) | |
tree | 574b81210ef3916b9a4ebf335e6e9b15dfde0fea /numpy/lib/_iotools.py | |
parent | fad376ead11b8e0f3101d37b62b0c8d5ba40af72 (diff) | |
download | numpy-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.py | 9 |
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) |