Re: [Numpy-discussion] Sum over array elements

2010-04-12 Thread Patrick Marsh
a = np.arange(10) b = (a[::2]).sum() Patrick On Mon, Apr 12, 2010 at 9:21 AM, Nicola Creati wrote: > Hello, > I want to calculate, given a one dimension array, the sum over every two > elements of the array. > I found this working solution: > > a = N.arange(10) > b = a.reshape(a, (5, 2)) >

Re: [Numpy-discussion] Sum over array elements

2010-04-12 Thread Gökhan Sever
On Mon, Apr 12, 2010 at 9:21 AM, Nicola Creati wrote: > Hello, > I want to calculate, given a one dimension array, the sum over every two > elements of the array. > I found this working solution: > > a = N.arange(10) > b = a.reshape(a, (5, 2)) > c = b.sum(axis=1) > > Is there any better solution?

[Numpy-discussion] Sum over array elements

2010-04-12 Thread Nicola Creati
Hello, I want to calculate, given a one dimension array, the sum over every two elements of the array. I found this working solution: a = N.arange(10) b = a.reshape(a, (5, 2)) c = b.sum(axis=1) Is there any better solution? Thanks, Nicola Creati ___