[Numpy-svn] r5798 - in branches/1.1.x/numpy/lib: . tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Tue Sep 9 10:03:24 EDT 2008
Author: stefan
Date: 2008-09-09 09:03:08 -0500 (Tue, 09 Sep 2008)
New Revision: 5798
Modified:
branches/1.1.x/numpy/lib/io.py
branches/1.1.x/numpy/lib/tests/test_io.py
Log:
Backport bugfix for #908 made on mainline in r5797.
Modified: branches/1.1.x/numpy/lib/io.py
===================================================================
--- branches/1.1.x/numpy/lib/io.py 2008-09-09 13:38:34 UTC (rev 5797)
+++ branches/1.1.x/numpy/lib/io.py 2008-09-09 14:03:08 UTC (rev 5798)
@@ -275,6 +275,8 @@
SeeAlso: scipy.io.loadmat to read and write matfiles.
"""
user_converters = converters
+ if usecols is not None:
+ usecols = list(usecols)
if _string_like(fname):
if fname.endswith('.gz'):
@@ -321,6 +323,8 @@
first_vals = None
while not first_vals:
first_line = fh.readline()
+ if first_line == '': # EOF reached
+ raise IOError('End-of-file reached before encountering data.')
first_vals = split_line(first_line)
N = len(usecols or first_vals)
Modified: branches/1.1.x/numpy/lib/tests/test_io.py
===================================================================
--- branches/1.1.x/numpy/lib/tests/test_io.py 2008-09-09 13:38:34 UTC (rev 5797)
+++ branches/1.1.x/numpy/lib/tests/test_io.py 2008-09-09 14:03:08 UTC (rev 5798)
@@ -82,7 +82,6 @@
y = np.loadtxt(d, dtype=mydescriptor)
assert_array_equal(y, b)
-
def test_array(self):
c = StringIO.StringIO()
c.write('1 2\n3 4')
@@ -163,6 +162,9 @@
x = np.loadtxt(c, dtype=float, usecols=(1,2))
assert_array_equal(x, a[:,1:])
+ def test_empty_file(self):
+ c = StringIO.StringIO()
+ assert_raises(IOError, np.loadtxt, c)
class Testfromregex(NumpyTestCase):
def test_record(self):
More information about the Numpy-svn
mailing list