Skip to content

Commit

Permalink
BUG: fix failing npyio test under py3k. Thanks to Derek Homeier. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Aug 10, 2011
1 parent 26aa3cf commit 57b56bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion numpy/lib/npyio.py
Expand Up @@ -763,6 +763,7 @@ def split_line(line):
# 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)
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions numpy/lib/tests/test_io.py
Expand Up @@ -392,6 +392,7 @@ def test_3d_shaped_dtype(self):
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,))
Expand Down

0 comments on commit 57b56bc

Please sign in to comment.