diff options
-rw-r--r-- | numpy/lib/npyio.py | 3 | ||||
-rw-r--r-- | numpy/lib/tests/test_io.py | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 44a91c0c7..6c4a9942f 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -763,6 +763,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, # End of lines reached first_line = '' first_vals = [] + warnings.warn('loadtxt: Empty input file: "%s"' % fname) N = len(usecols or first_vals) dtype_types, packing = flatten_dtype(dtype) @@ -1275,7 +1276,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, first_values = split_line(first_line) except StopIteration: # return an empty array if the datafile is empty - first_line = '' + first_line = asbytes('') first_values = [] warnings.warn('genfromtxt: Empty input file: "%s"' % fname) diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 18585375e..8bfb64cee 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -392,6 +392,7 @@ class TestLoadTxt(TestCase): assert_array_equal(x, a) def test_empty_file(self): + warnings.filterwarnings("ignore", message="loadtxt: Empty input file:") c = StringIO() x = np.loadtxt(c) assert_equal(x.shape, (0,)) |