The reason why we don't have that extra slice is because we may not know ahead of time that we are dealing with a 2D array. It could be a 1D array. I guess we could use ellipses, but I wanted to make sure that the numpy devs consider the above to be perfectly valid semantics because it is entrenched in our codebase.

Ben Root

On Thu, Aug 27, 2015 at 11:33 AM, Sebastian Berg <sebastian@sipsolutions.net> wrote:
On Do, 2015-08-27 at 11:15 -0400, Benjamin Root wrote:
> Ok, I just wanted to make sure I understood the issue before going bug
> hunting. Chances are, it has been a bug on our end for a while now.
> Just to make sure, is the following valid?
>
>
> arr = np.zeros((5, 3))
>
> ind = np.array([True, True, True, False, True])
>
> arr[ind]   # gives a 4x3 result
>
>
> Running that at the REPL doesn't produce a warning, so i am guessing
> that it is valid.
>

Sure, that is perfect (you can add the slice and write `arr[ind, :]` to
make it a bit more clear if you like I guess).

- Sebastian


>
> Ben Root
>
>
> On Thu, Aug 27, 2015 at 10:44 AM, Sebastian Berg
> <sebastian@sipsolutions.net> wrote:
>         On Do, 2015-08-27 at 08:04 -0600, Charles R Harris wrote:
>         >
>         >
>         > On Thu, Aug 27, 2015 at 7:52 AM, Benjamin Root
>         <ben.v.root@gmail.com>
>         > wrote:
>         >
>         >
>         >         Ok, I tested matplotlib master against numpy master,
>         and there
>         >         were no errors. I did get a bunch of new deprecation
>         warnings
>         >         though such as:
>         >
>         >
>          "/nas/home/broot/centos6/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-linux-x86_64.egg/matplotlib/colorbar.py:539: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 5 but corresponding boolean dimension is 3
>         >           colors = np.asarray(colors)[igood]"
>         >
>         >
>         >         The message isn't exactly clear. I suspect the
>         problem is a
>         >         shape mismatch, like colors is 5x3, and igood is
>         just 3 for
>         >         some reason. Could somebody shine some light on
>         this, please?
>         >
>         >
>         >
>         > IIRC, Boolean indexing would fill out the dimension, i.e.,
>         len 3 would
>         > be expanded to len 5 in this case. That behavior is
>         deprecated.
>         >
>
>         Yes, this is exactly the case, you have something like:
>
>         arr = np.zeros((5, 3))
>         ind = np.array([True, False, False])
>         arr[ind, :]
>
>         and numpy nowadays thinks that such code is likely a bug (when
>         the ind
>         is shorter than arr it is somewhat OK, the other way around
>         gets more
>         creepy). If you have an idea of how to make the error message
>         clearer,
>         or objections to the change, I am happy to hear it!
>
>         - Sebastian
>
>
>         >
>         > Chuck
>         >
>         >
>         >
>         > _______________________________________________
>         > NumPy-Discussion mailing list
>         > NumPy-Discussion@scipy.org
>         > http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
>         _______________________________________________
>         NumPy-Discussion mailing list
>         NumPy-Discussion@scipy.org
>         http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion


_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion