On Mon, Aug 8, 2016 at 6:11 AM, Anakim Border <akbor...@gmail.com> wrote:

> Alternative version:
>
> >>> a = np.arange(10)
> >>> a[np.array([1,6,5])] += 1
> >>> a
> array([0, 2, 2, 3, 4, 6, 7, 7, 8, 9])
>

I haven't checked, but a likely explanation is that Python itself
interprets a[b] += c as a[b] = a[b] + c.

Python has special methods for inplace assignment (__setitem__) and inplace
arithmetic (__iadd__) but no special methods for inplace arithmetic and
assignment at the same time, so this is really out of NumPy's control here.
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to