[NumPy-Tickets] [NumPy] #2037: genfromtxt with dtype different behavior in 32bit or 64bit numpy
NumPy Trac
numpy-tickets@scipy....
Fri Feb 3 02:04:18 CST 2012
#2037: genfromtxt with dtype different behavior in 32bit or 64bit numpy
------------------------+---------------------------------------------------
Reporter: risotto | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: 1.6.1
Keywords: genfromtxt |
------------------------+---------------------------------------------------
I've got installed on one machine (debian linux 6) numpy in 32bit, with
virtual environment, and on the other machine is numpy in 64bit installed
via virtual environment.
There's an issue, if in your file is an float value, but want to read it
as integer. The example will be more apparent.
On 32bit:
{{{
>>> import sys
>>> sys.maxint
2147483647
>>> from StringIO import StringIO
>>> import numpy as np
>>> s = StringIO("333 12.5 22")
>>> data = np.genfromtxt(s, dtype=[('x', float), ('y', int), ('z', int)])
>>> data
array((333.0, 12, 22),
dtype=[('x', '<f8'), ('y', '<i4'), ('z', '<i4')])
>>> s = StringIO("333 12.5 22")
>>> data = np.genfromtxt(s, dtype=[('x', float), ('y', long), ('z', int)])
>>> data
array((333.0, -1L, 22),
dtype=[('x', '<f8'), ('y', '<i8'), ('z', '<i4')])
}}}
On 64bit:
{{{
>>> import sys
>>> sys.maxint
9223372036854775807
>>> from StringIO import StringIO
>>> import numpy as np
>>> s = StringIO("333 12.5 22")
>>> data = np.genfromtxt(s)
>>> data
array([ 333. , 12.5, 22. ])
>>> s = StringIO("333 12.5 22")
>>> data = np.genfromtxt(s, dtype=[('x', float), ('y', int), ('z', int)])
>>> data
array((333.0, -1, 22),
dtype=[('x', '<f8'), ('y', '<i8'), ('z', '<i8')])
>>> s = StringIO("333 12.5 22")
>>> data = np.genfromtxt(s, dtype=[('x', float), ('y', long), ('z', int)])
>>> data
array((333.0, 12L, 22),
dtype=[('x', '<f8'), ('y', '<i8'), ('z', '<i8')])
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2037>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list