Skip to content

a.cumsum(dtype=xxx) results bad when len(a) > 10001 (Trac #165) #763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
numpy-gitbot opened this issue Oct 19, 2012 · 1 comment
Closed

Comments

@numpy-gitbot
Copy link

Original ticket http://projects.scipy.org/numpy/ticket/165 on 2006-07-03 by trac user cpl, assigned to unknown.

cumsum with any meaningful dtype, on any array larger than 10001 items, has incorrect output. For the 10002-element case, the [1] and [-1] entries are wrong; for a 10003-element array, items (1,2,-2,-1) are bad.
I briefly looked for PyArray_BUFSIZE-related botches, but am confused enough by the code flow to not have gotten very far.

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
numpy.version
'0.9.9.2707'
a = numpy.arange(10002)
a.cumsum(dtype='f8')
array([ 0.00000000e+00, 1.00010000e+04, 3.00000000e+00, ...,
4.99950000e+07, 5.00050000e+07, 0.00000000e+00])
a.cumsum(dtype='i2')
array([ 0, 10001, 3, ..., -8968, 1032, 0], dtype=int16)
b = numpy.arange(30000)
a.cumsum(dtype='f8')
array([ 0.00000000e+00, 1.00010000e+04, 3.00000000e+00, ...,
4.99950000e+07, 5.00050000e+07, 0.00000000e+00])

@numpy-gitbot
Copy link
Author

@teoliphant wrote on 2006-07-06

This was a problem in the BUFFERED section of accumulate. The problem was also present in reduce, and reduceat.

Buffered code can be checked for smaller sizes by setting the buffer size to a smaller multiple of 16.

setbufsize(5*16) # for example.

This was fixed in r2738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant