scalar object bug or feature?

Christopher Hanley chanley at stsci.edu
Wed Oct 18 14:10:08 CDT 2006


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'>



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Numpy-discussion mailing list