[Numpy-discussion] NEP 21: Simplified and explicit advanced indexing

Sebastian Berg sebastian at sipsolutions.net
Tue Jun 26 04:41:24 EDT 2018

On Tue, 2018-06-26 at 04:23 -0400, Hameer Abbasi wrote:
> > Boolean indices are not supported. All indices must be integers,
> integer arrays or slices.
> I would hope that there’s at least some way to do boolean indexing. I
> often find myself needing it. I realise that
> `arr.vindex[np.nonzero(boolean_idx)]` works, but it is slightly too
> verbose for my liking. Maybe we can have `arr.bindex[boolean_index]`
> as an alias to exactly that?

That part is limited to `vindex` only. A single boolean index would
always work in plain indexing and you can mix it all up inside of
`oindex`. But with fancy indexing mixing boolean + integer seems
currently pretty much useless (and thus the same is true for `vindex`,
in `oindex` things make sense).
Now you could invent some new logic for such a mixing case in `vindex`,
but it seems easier to just ignore it for the moment.

- Sebastian

> Or is boolean indexing preserved as-is n the newest proposal? If so,
> great!
> Another thing I’d say is `arr.?index` should be replaced with
> `arr.?idx`. I personally prefer `arr.?x` for my fingers but I realise
> that for someone not super into NumPy indexing, this is kind of
> opaque to read, so I propose this less verbose but hopefully equally
> clear version, for my (and others’) brains.
> Best Regards,
> Hameer Abbasi
> Sent from Astro for Mac
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180626/0cf50f9c/attachment.sig>

More information about the NumPy-Discussion mailing list