diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/_iotools.py | 4 | ||||
-rw-r--r-- | numpy/lib/recfunctions.py | 13 | ||||
-rw-r--r-- | numpy/lib/tests/test__iotools.py | 5 |
3 files changed, 16 insertions, 6 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index 27143e5c6..b604b8c52 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -205,7 +205,11 @@ class LineSplitter(object): # def __init__(self, delimiter=None, comments='#', autostrip=True, encoding=None): + delimiter = _decode_line(delimiter) + comments = _decode_line(comments) + self.comments = comments + # Delimiter is a character if (delimiter is None) or isinstance(delimiter, basestring): delimiter = delimiter or None diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py index e9ba38f46..c455bd93f 100644 --- a/numpy/lib/recfunctions.py +++ b/numpy/lib/recfunctions.py @@ -397,12 +397,13 @@ def merge_arrays(seqarrays, fill_value=-1, flatten=False, Notes ----- * Without a mask, the missing value will be filled with something, - * depending on what its corresponding type: - -1 for integers - -1.0 for floating point numbers - '-' for characters - '-1' for strings - True for boolean values + depending on what its corresponding type: + + * ``-1`` for integers + * ``-1.0`` for floating point numbers + * ``'-'`` for characters + * ``'-1'`` for strings + * ``True`` for boolean values * XXX: I just obtained these values empirically """ # Only one item in the input sequence ? diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py index 5f6c29a4d..b4888f1bd 100644 --- a/numpy/lib/tests/test__iotools.py +++ b/numpy/lib/tests/test__iotools.py @@ -53,6 +53,11 @@ class TestLineSplitter(object): test = LineSplitter(',')(strg) assert_equal(test, ['1', '2', '3', '4', '', '5']) + # gh-11028 bytes comment/delimiters should get encoded + strg = b" 1,2,3,4,,5 % test" + test = LineSplitter(delimiter=b',', comments=b'%')(strg) + assert_equal(test, ['1', '2', '3', '4', '', '5']) + def test_constant_fixed_width(self): "Test LineSplitter w/ fixed-width fields" strg = " 1 2 3 4 5 # test" |