[Numpy-discussion] bug triggered by array.astype()
oliphant.travis at ieee.org
Sun Jan 29 00:25:04 CST 2006
Gerard Vermeulen wrote:
>>>>from numpy import *
>>>>v = linspace(0, 2*pi)
>>>>c = (255<<24)*cos(v) + (255<<16)*cos(v+2*pi/3) + (255<<8)*cos(v+4*pi/3) + 255
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
>SystemError: Objects/longobject.c:257: bad argument to internal function
Thanks for this test. The problem stems from the (255<<24) which (on
32-bit platform) generates a long-integer object. Currently,
long-integers are converted to object arrays, thus this operation causes
your entire calculation to be done using Python objects.
Then, you try to convert the whole thing to UInt32 which is giving the
error. I'll look into the error.
In the meantime, you can avoid going through object arrays using an
int64(255<24)*cos(v) + ...
More information about the Numpy-discussion