[Numpy-tickets] [NumPy] #623: loadtxt fails with record arrays
NumPy
numpy-tickets@scipy....
Fri Apr 4 12:33:30 CDT 2008
#623: loadtxt fails with record arrays
------------------------+---------------------------------------------------
Reporter: mstarzyk | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0.5
Component: numpy.core | Version:
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by bsouthey):
With 1.0.5.dev4961, this fails if incorrect dtype of a float instead of an
int is being used whereas NumPy array() does not fail. Based on the test
and array wiki documentation:
{{{
import numpy as np
import StringIO
d2 = StringIO.StringIO()
d2.write('M 64.0 75.0\nF 25.0 60.0')
d2.seek(0)
mydescriptor = {'names': ('gender','age','weight'), 'formats': ('S1',
'i4', 'f4')}
b2 = np.array([('M', 64.0, 75.0),('F', 25.0, 60.0)], dtype=mydescriptor)
print b2
y2 = np.loadtxt(d2, dtype=mydescriptor)
}}}
Gives:
{{{
[('M', 64, 75.0) ('F', 25, 60.0)]
y2 = np.loadtxt(d2, dtype=mydescriptor)
File "/usr/local/lib64/python2.5/site-packages/numpy/lib/io.py", line
310, in loadtxt
row = [converterseq[j](val) for j,val in enumerate(vals)]
ValueError: invalid literal for int() with base 10: '64.0'
}}}
Note that if f4 instead of i4 is used, it works.
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/623#comment:3>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list