> There is a way that will generally work using triple indexing:
>
> arr[..., None, None][orig_indx + (slice(None), np.array(0))][..., 0]

Impressive! (note: I fixed the * typo in the quote)

> The first and last indexing operation is just a view creation, so it is
> basically a no-op. Now doing this gives me the shiver, but it will work
> always. If you want to have a no-copy behaviour in case your original
> index is ont an advanced indexing operation, you should replace the
> np.array(0) with just 0.

I agree about the shivers, but any workaround is good to have nonetheless.

If the index is not an advanced indexing operation, does it not suffice to
simply apply the index tuple as-is?

Michael
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to