[Numpy-tickets] [NumPy] #549: int() of numpy scalar fails silently
NumPy
numpy-tickets@scipy....
Wed Jul 11 15:09:22 CDT 2007
#549: int() of numpy scalar fails silently
------------------------+---------------------------------------------------
Reporter: zouave | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0.4 Release
Component: numpy.core | Version: devel
Severity: major | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by zouave):
I just added a patch that should solve most conversions of numarray
scalars to python ints.
e.g.
{{{
from numpy import *
l= [1e6, 1e12, 1e18, -1e6, -1e12, -1e18]
af64= array(l, dtype='float64')
ai64= array(l, dtype='int64')
aui64= array(l[:3], dtype='uint64')
il= map(int, l)
iaf64= map(int, af64)
iai64= map(int, ai64)
iaui64= map(int, aui64)
print il
print iaf64
print iai64
print iaui64
}}}
Output before patch:
{{{
[1000000, 1000000000000L, 1000000000000000000L, -1000000, -1000000000000L,
-1000000000000000000L]
[1000000, -2147483648, -2147483648, -1000000, -2147483648, -2147483648]
[1000000, -727379968, -1486618624, -1000000, 727379968, 1486618624]
[1000000, -727379968, -1486618624]
}}}
Output after patch:
{{{
[1000000, 1000000000000L, 1000000000000000000L, -1000000, -1000000000000L,
-1000000000000000000L]
[1000000, 1000000000000L, 1000000000000000000L, -1000000, -1000000000000L,
-1000000000000000000L]
[1000000, 1000000000000L, 1000000000000000000L, -1000000, -1000000000000L,
-1000000000000000000L]
[1000000, 1000000000000L, 1000000000000000000L]
}}}
Does it look ok to numpy's gurus? If so, can it be applied to the svn
repository? Or, can I commit this change myself?
Thanks,
Xavier
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/549#comment:2>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list