[Numpy-discussion] BUG in numpy.loadtxt?
Ryan May
rmay31 at gmail.com
Thu Sep 4 14:08:17 EDT 2008
Stefan (or anyone else who can comment),
It appears that the usecols argument to loadtxt no longer accepts numpy
arrays:
>>>from StringIO import StringIO
>>>text = StringIO('1 2 3\n4 5 6\n')
>>>data = np.loadtxt(text, usecols=np.arange(1,3))
ValueError Traceback (most recent call last)
/usr/lib64/python2.5/site-packages/numpy/lib/io.py in loadtxt(fname,
dtype, comments, delimiter, converters, skiprows, usecols, unpack)
323 first_line = fh.readline()
324 first_vals = split_line(first_line)
--> 325 N = len(usecols or first_vals)
326
327 dtype_types = flatten_dtype(dtype)
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
>>>data = np.loadtxt(text, usecols=np.arange(1,3).tolist())
>>>data
array([[ 2., 3.],
[ 5., 6.]])
Was it a conscious design decision that the usecols no longer accept
arrays? The new behavior (in 1.1.1) breaks existing code that one of my
colleagues has. Can we get a patch in before 1.2 to get this working
with arrays again?
Thanks,
Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
More information about the NumPy-Discussion
mailing list