[Numpy-discussion] subtle behavior when subtracting sub-arrays
Pauli Virtanen
pav at iki.fi
Mon Jul 5 10:23:58 EDT 2010
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] itself is changed during the loop, while in the former
> case, numpy makes a copy of a[...,0] ?
Correct.
> Is this intended?
Not really. It's a "feature" we're planning to get rid of eventually,
once a way to do it without sacrificing performance in "safe" cases is
implemented.
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list