Skip to content

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

Closed

Description

@numpy-gitbot

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])

Activity

  1. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions