diff options
author | Leonardo Donelli <learts92@gmail.com> | 2014-10-05 16:27:02 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2015-01-25 17:02:17 +0100 |
commit | 79ac5766255e54ea5206e44972beb3563eb4676f (patch) | |
tree | a4d0b27e08651a2aa049df7a83c62c2ad26a99a3 | |
parent | 6fde11b5e0849198df23e3945540a5e3e132c10b (diff) | |
download | numpy-79ac5766255e54ea5206e44972beb3563eb4676f.tar.gz |
BUG: Fix loadtxt with comments=None and a string None data.
Current loadtxt with `comments=None` considers the string `'None'` as a
comment symbol. Fixed by making split_line method check if comments is
None.
Closes #5155.
-rw-r--r-- | numpy/lib/npyio.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 641203f34..bc86cf5ea 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -717,7 +717,8 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, """ # Type conversions for Py3 convenience - comments = asbytes(comments) + if comments is not None: + comments = asbytes(comments) user_converters = converters if delimiter is not None: delimiter = asbytes(delimiter) @@ -790,7 +791,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, def split_line(line): """Chop off comments, strip, and split at delimiter.""" - line = asbytes(line).split(comments)[0].strip(asbytes('\r\n')) + if comments is None: + line = asbytes(line).strip(asbytes('\r\n')) + else: + line = asbytes(line).split(comments)[0].strip(asbytes('\r\n')) if line: return line.split(delimiter) else: |