[Numpy-discussion] DEP: Deprecate boolean array indices with non-matching shape #4353

Anne Archibald archibald at astron.nl
Fri Jun 5 11:50:04 EDT 2015

On Fri, Jun 5, 2015 at 5:45 PM Sebastian Berg <sebastian at sipsolutions.net>

> On Fr, 2015-06-05 at 08:36 -0400, josef.pktd at gmail.com wrote:
> >
> <snip>
> >
> > What is actually being deprecated?
> > It looks like there are different examples.
> >
> >
> > wrong length: Nathaniels first example above, where the mask is not
> > broadcastable to original array because mask is longer or shorter than
> > shape[axis].
> > I also wouldn't have expected this to work, although I use np.nozero
> > and boolean mask indexing interchangeably, I would assume we need the
> > correct length for the mask.
> >
> For the moment we are only talking about wrong length (along a given
> dimension). Not about wrong number of dimensions or multiple boolean
> indices.

I am pro-deprecation then, definitely. I don't see a use case for padding a
wrong-shaped boolean array with Falses, and the padding has burned me in
the past.

It's not orthogonal to the wrong-number-of-dimensions issue, though,
because if your Boolean array has a dimension of length 1, broadcasting
says duplicate it along that axis to match the indexee, and wrong-length
says pad it with Falses. This ambiguity/pitfall disappears if the padding
never happens, and that kind of broadcasting is very useful.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150605/e9f5bea2/attachment.html>

More information about the NumPy-Discussion mailing list