`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:scan... `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.dawson@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`.