![](https://secure.gravatar.com/avatar/764323a14e554c97ab74177e0bce51d4.jpg?s=120&d=mm&r=g)
20 May
2021
20 May
'21
6:46 p.m.
On Thu, May 20, 2021 at 1:40 PM CJ Carey <perimosocordiae@gmail.com> wrote:
Or as a one-liner:
out[np.arange(len(x)), x] = 1
Ah, right. `x[arange(len(x))]` is a no-op.
If NEP 21 is accepted ( https://numpy.org/neps/nep-0021-advanced-indexing.html) this would be even simpler:
out.vindex[:, x] = 1
Was there ever a decision about that NEP? I didn't follow the discussion too closely at the time.
IIRC, I think there was broad agreement on the final plan as stated in the NEP. I suspect, though, that the general appetite for adding to the array API surface has declined even from its anemic starting point, now that deep learning frameworks with ndarray-mimicking APIs have taken off. -- Robert Kern