[Numpy-discussion] implicit coersion int8 -> int16 ?

Simon Burton simon at arrowtheory.com
Sat May 20 19:43:02 EDT 2006


>>> a=numpy.array([1,2,3],numpy.Int8)
>>> a
array([1, 2, 3], dtype=int8)
>>> a*2
array([2, 4, 6], dtype=int16)
>>> 

My little 2 lives happily as an int8, so why is the int8 array
cast to an int16 ?
I spent quite a while finding this bug.

Furthermore, this works:
>>> a*a
array([1, 4, 9], dtype=int8)

but not this:
>>> a*numpy.array(2,dtype=numpy.Int8)
array([2, 4, 6], dtype=int16)

>>> print numpy.__version__
0.9.9.2533

Simon.

-- 
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com 




More information about the NumPy-Discussion mailing list