[Numpy-discussion] numpy type mismatch

Benjamin Root ben.root@ou....
Fri Jun 10 14:50:32 CDT 2011

Came across an odd error while using numpy master.  Note, my system is

>>> import numpy as np
>>> type(np.sum([1, 2, 3], dtype=np.int32)) == np.int32
>>> type(np.sum([1, 2, 3], dtype=np.int64)) == np.int64
>>> type(np.sum([1, 2, 3], dtype=np.float32)) == np.float32
>>> type(np.sum([1, 2, 3], dtype=np.float64)) == np.float64

So, only the summation performed with a np.int32 accumulator results in a
type that doesn't match the expected type.  Now, for even more strangeness:

>>> type(np.sum([1, 2, 3], dtype=np.int32))
<type 'numpy.int32'>
>>> hex(id(type(np.sum([1, 2, 3], dtype=np.int32))))
>>> hex(id(np.int32))

So, the type from the sum() reports itself as a numpy int, but its memory
address is different from the memory address for np.int32.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110610/d929eee7/attachment.html 

More information about the NumPy-Discussion mailing list