Re: [Numpy-discussion] summing an array

2011-08-19 Thread Bob Dowling
On 19/08/11 15:49, Chris Withers wrote: > On 18/08/2011 07:58, Bob Dowling wrote: >> >> >>> numpy.add.accumulate(a) >> array([ 0, 1, 3, 6, 10]) >> >> >>> numpy.add.accumulate(a, out=a) >> array([ 0, 1, 3, 6, 10]) > > What's the difference between numpy.cumsum and numpy.add.accumulate? I think the

Re: [Numpy-discussion] summing an array

2011-08-19 Thread Chris Withers
On 18/08/2011 07:58, Bob Dowling wrote: > > >>> numpy.add.accumulate(a) > array([ 0, 1, 3, 6, 10]) > > >>> numpy.add.accumulate(a, out=a) > array([ 0, 1, 3, 6, 10]) What's the difference between numpy.cumsum and numpy.add.accumulate? Where can I find the reference docs for these? che

Re: [Numpy-discussion] summing an array

2011-08-18 Thread Bob Dowling
On 18/08/11 15:19, Chris Withers wrote: > Hopefully a simple newbie question, if I have an array such as : > > array([0, 1, 2, 3, 4]) > > ...what's the best way to cummulatively sum it so that I end up with: > > array([0, 1, 3, 6, 10]) > > How would I do this both in-place and to create a new arr

Re: [Numpy-discussion] summing an array

2011-08-18 Thread Skipper Seabold
On Thu, Aug 18, 2011 at 10:19 AM, Chris Withers wrote: > Hi All, > > Hopefully a simple newbie question, if I have an array such as : > > array([0, 1, 2, 3, 4]) > > ...what's the best way to cummulatively sum it so that I end up with: > > array([0, 1, 3, 6, 10]) > > How would I do this both in-pla

[Numpy-discussion] summing an array

2011-08-18 Thread Chris Withers
Hi All, Hopefully a simple newbie question, if I have an array such as : array([0, 1, 2, 3, 4]) ...what's the best way to cummulatively sum it so that I end up with: array([0, 1, 3, 6, 10]) How would I do this both in-place and to create a new array? cheers, Chris -- Simplistix - Content M

Re: [Numpy-discussion] Summing an array with dtype=object

2009-11-15 Thread Pierre GM
On Nov 16, 2009, at 12:16 AM, Robert Kern wrote: > On Sun, Nov 15, 2009 at 23:11, Pierre GM wrote: >> All, >> An issue was recently raised about summing a MaskedArray with a np.object >> dtype. Turns out that the problem is numpy based: >> Let's sum using integers > type(np.sum([1,2,3], dty

Re: [Numpy-discussion] Summing an array with dtype=object

2009-11-15 Thread Robert Kern
On Sun, Nov 15, 2009 at 23:11, Pierre GM wrote: > All, > An issue was recently raised about summing a MaskedArray with a np.object > dtype. Turns out that the problem is numpy based: > Let's sum using integers type(np.sum([1,2,3], dtype=np.int32)) > > > Now, with a np.object dtype:  ty

[Numpy-discussion] Summing an array with dtype=object

2009-11-15 Thread Pierre GM
All, An issue was recently raised about summing a MaskedArray with a np.object dtype. Turns out that the problem is numpy based: Let's sum using integers >>> type(np.sum([1,2,3], dtype=np.int32)) Now, with a np.object dtype: >>> type(np.sum([1,2,3],dtype=object)) And we no longer have a np.o