Re: [Numpy-discussion] subtle behavior when subtracting sub-arrays

2010-07-05 Thread Pauli Virtanen
Mon, 05 Jul 2010 16:03:56 +0200, Steve Schmerler wrote: [clip] > To sum up, I find it a bit subtle that > a = a - a[...,0][...,None] > works as expected, while > a -= a[...,0][...,None] > does not. > I guess the reason is that in the latter case (and the corresponding > loop), a[...,0] itse

[Numpy-discussion] subtle behavior when subtracting sub-arrays

2010-07-05 Thread Steve Schmerler
Hi I stumbled upon some numpy behavior which I was not aware of. Say I have an array of shape (2,2,3) and want to subtract the sub-array a[...,0] of shape (2,2) from each a[...,i], i=0,1,2 . ## ok ## In [1]: a=arange(2*2*3).reshape(2,2,3) # Copy the array to be subtracted. In [