[Numpy-discussion] Using array mask swaps array axes

Benjamin Root ben.root at ou.edu
Wed Oct 16 11:50:03 EDT 2013


On Wed, Oct 16, 2013 at 11:39 AM, Chad Kidder <cckidder at gmail.com> wrote:

> Just found what should be a bug in 1.7.1.  I'm running python(x,y) on
> windows here:
>
> >>> dataMatrix[ii,:,mask].shape
> (201, 23)
> >>> dataMatrix[ii,:,:].shape
> (23, 201)
> >>> dataMatrix.shape
> (24, 23, 201)
> >>> mask
> array([ True,  True,  True,  True,  True,  True,  True,  True,  True,
>         ...
>         True,  True,  True], dtype=bool)
>
> using a mask should not change the order of the dimensions.  Is there a
> reason for this behavior, and if so, how do I avoid it in the future?
> Thanks
>
>      --Chad Kidder
>
>
Chad,

The issue here is one where there is the mixing of fancy indexing (I
presume that is what "ii" is), slicing and boolean indexing. If I remember
correctly, the changing of the dimension orders was an inadvertent
byproduct of handing all this array accessing methods in one shot. I think
this was addressed in 1.8. Sorry for being very brief and vague, hopefully
someone else who understands what the resolution was can fill in.

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


More information about the NumPy-Discussion mailing list