`cumsum` provides a sequence of partial sums, exactly as expected.
https://reference.wolfram.com/language/ref/Accumulate.html
https://www.mathworks.com/help/matlab/ref/cumsum.html
https://docs.julialang.org/en/v1/base/arrays/#Base.cumsum
https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:scanl1

`diff` also behaves as expected, and as you expect.
But I do not think that is the question.
The question is, how useful would it be for numpy to have a
less commonly needed and closely related function.
(I have no need of it, and I don't really see a pressing need.)



On 8/22/2023 10:36 AM, john.daw...@camlingroup.com wrote:
For n values there are n-1 differences. Equivalently, for k differences there 
are k+1 values. Herefor, `diff` ought to reduce length by 1 and `cumsum` ought 
to increase it by 1. Returning arrays of the same length is a fencepost error. 
This is a problem in the current behaviour of `cumsum` and the proposed 
behaviour of `diff0`.
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to