From: Christopher H. <ch...@st...> - 2006-10-18 19:10:19
|
Greetings, I can't decide if the following is a bug or feature. Numpy scalars are allowed to overflow silently while numarray upcasts to a larger python type. I guess my biggest problem is that the overflow occurs silently. In any case, is this known and expected behavior? Thanks, Chris NUMARRAY example: In [1]: import numarray as n In [2]: a = n.array([2200,14000],type=n.UInt32) In [3]: a0= a[0] In [4]: a1 = a[1] In [5]: adiff = a0-a1 In [6]: print a0,a1,adiff 2200 14000 -11800 In [7]: print type(a0),type(a1),type(adiff) <type 'long'> <type 'long'> <type 'long'> NUMPY example: In [1]: import numpy as n In [2]: a = n.array([2200,14000],dtype=n.uint32) In [3]: a0= a[0] In [4]: a1 = a[1] In [5]: adiff = a0-a1 In [6]: print a0,a1,adiff 2200 14000 4294955496 In [7]: print type(a0),type(a1),type(adiff) <type 'numpy.uint32'> <type 'numpy.uint32'> <type 'numpy.uint32'> |