[Numpy-discussion] Can't mix np.newaxis with boolean indexing

Benjamin Root ben.root at ou.edu
Sun Aug 21 16:39:02 EDT 2011


On Sunday, August 21, 2011, Torgil Svensson <torgil.svensson at gmail.com>
wrote:
> Since the result is one-dimensional after using boolean indexing you
> can always do:
>
> a[b][:, np.newaxis]
> array([[2],
>         [3],
>         [4]])
>
> a[b][np.newaxis, :]
> array([[2, 3, 4]])
>
> //Torgil

Correct, which I already noted as a workaround in my first email.  The point
I am making is that that shouldn't be necessary because of generic
programming concepts, or a better error message should be emitted in case a
developer didn't know that he was doing Boolean indexing.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110821/f9850bfb/attachment.html>


More information about the NumPy-Discussion mailing list