[Numpy-discussion] Array addition inconsistency

2013-08-29 Thread Martin Luethi
Dear all, After some surprise, I noticed an inconsistency while adding array slices: a = np.arange(5) a[1:] = a[1:] + a[:-1] a array([0, 1, 3, 5, 7]) versus inplace a = np.arange(5) a[1:] += a[:-1] a array([ 0, 1, 3, 6, 10]) My suspicition is that the second variant does not create

Re: [Numpy-discussion] Array addition inconsistency

2013-08-29 Thread Robert Kern
On Thu, Aug 29, 2013 at 12:00 PM, Martin Luethi lue...@vaw.baug.ethz.ch wrote: Dear all, After some surprise, I noticed an inconsistency while adding array slices: a = np.arange(5) a[1:] = a[1:] + a[:-1] a array([0, 1, 3, 5, 7]) versus inplace a = np.arange(5) a[1:] += a[:-1]

Re: [Numpy-discussion] Array addition inconsistency

2013-08-29 Thread Benjamin Root
On Thu, Aug 29, 2013 at 8:04 AM, Robert Kern robert.k...@gmail.com wrote: On Thu, Aug 29, 2013 at 12:00 PM, Martin Luethi lue...@vaw.baug.ethz.ch wrote: Dear all, After some surprise, I noticed an inconsistency while adding array slices: a = np.arange(5) a[1:] = a[1:] + a[:-1]

Re: [Numpy-discussion] Array addition inconsistency

2013-08-29 Thread josef . pktd
On Thu, Aug 29, 2013 at 9:39 AM, Benjamin Root ben.r...@ou.edu wrote: On Thu, Aug 29, 2013 at 8:04 AM, Robert Kern robert.k...@gmail.comwrote: On Thu, Aug 29, 2013 at 12:00 PM, Martin Luethi lue...@vaw.baug.ethz.ch wrote: Dear all, After some surprise, I noticed an inconsistency