diff options
author | gfyoung <gfyoung17@gmail.com> | 2016-12-06 14:48:03 -0500 |
---|---|---|
committer | gfyoung <gfyoung17@gmail.com> | 2016-12-08 12:40:39 -0500 |
commit | df00a6fa1afca742288a75c7b883f901668e0619 (patch) | |
tree | c040c8d315a812a7f00c471dfb74ee7b883917ee /numpy/lib/tests/test_io.py | |
parent | 62694d219bd4c768bcd93b85257298bd656817c9 (diff) | |
download | numpy-df00a6fa1afca742288a75c7b883f901668e0619.tar.gz |
BUG: Apply more robust string converts in loadtxt
The original dtype converters for bytes and str
did not account for converting objects of str or
bytes dtype respectively. Replace the original
converters with those from numpy.compat, which
are much more robust.
Closes gh-8033.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r-- | numpy/lib/tests/test_io.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 333891d46..61c9c0636 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -686,6 +686,15 @@ class TestLoadTxt(TestCase): dtype=dt) assert_array_equal(x, a) + def test_str_dtype(self): + # see gh-8033 + c = ["str1", "str2"] + + for dt in (str, np.bytes_): + a = np.array(["str1", "str2"], dtype=dt) + x = np.loadtxt(c, dtype=dt) + assert_array_equal(x, a) + def test_empty_file(self): with suppress_warnings() as sup: sup.filter(message="loadtxt: Empty input file:") |