[Numpy-discussion] Bug with cumsum(dtype='f8')?

Craig Loomis cloomis at astro.princeton.edu
Wed Jun 21 12:41:14 EDT 2006


    Not sure if this one has been addressed. There appears to be a  
problem with cumsum(dtype=), with reasonably small numbers. Both PPC  
and x86 Macs.

========

import numpy

print "numpy version:", numpy.__version__

v = numpy.arange(10002)                 # 10001 is OK, larger is "worse"
print "ok:     ", v.cumsum()
print "not ok: ", v.cumsum(dtype=numpy.float64)
print "ok:     ", numpy.arange(10002,dtype=numpy.float64).cumsum()

=========


ActivePython 2.4.3 Build 11 (ActiveState Software Inc.) based on
Python 2.4.3 (#1, Apr  3 2006, 18:07:14)
[GCC 4.0.1 (Apple Computer, Inc. build 5247)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> print "numpy version:", numpy.__version__
numpy version: 0.9.9.2549
 >>> v = numpy.arange(10002)                 # 10001 is OK, larger is  
"worse"
 >>> print "ok:     ", v.cumsum()
ok:      [       0        1        3 ..., 49995000 50005000 50015001]
 >>> print "not ok: ", v.cumsum(dtype=numpy.float64)
not ok:  [  0.00000000e+00   1.00010000e+04   3.00000000e+00 ...,    
4.99950000e+07
    5.00050000e+07   0.00000000e+00]
 >>> print "ok:     ", numpy.arange(10002,dtype=numpy.float64).cumsum()
ok:      [  0.00000000e+00   1.00000000e+00   3.00000000e+00 ...,    
4.99950000e+07
    5.00050000e+07   5.00150010e+07]
 >>>


  - craig




More information about the NumPy-Discussion mailing list