[Numpy-discussion] boolean indexing change
Thu Jun 14 16:38:26 CDT 2012
On Mon, Jun 11, 2012 at 1:31 AM, Travis Oliphant <email@example.com> wrote:
> It is unfortunate that this was committed to master. This should be backed out and is a blocker for 1.7. Can someone help me identify which commit made the change?
> This is a rather significant change and changes the documented behavior of NumPy substantially. This should definitely not occur in 1.7
> The documented behavior (Guide to NumPy, pg. 84) of boolean indexing is that
> x[obj] is equivalent to x[obj.nonzero()]
> The shape of advanced indexing is not restricted to the shape of of x. I suspect this change was made when it was presumed the next release would be 2.0 and such behavior could presumably be changed somewhat? But, was there a discussion about this?
I don't see the commit where the change was made (the release notes
were updated at some other time), but that error message seems to come
from nditer. So I suspect that this change was part of the rewrite of
indexing, and might not be fixable with a small local patch -- I don't
think nditer has a way to iterate over a boolean array while filling
in False once you go past the end of the array...
If we're willing to deprecate this behavior then a temporary
workaround measure might be enough. Like checking for such arrays and
copying them into larger arrays before using them in indexing. Or
maybe that would be fine in general, I dunno. Mark, any thoughts?
More information about the NumPy-Discussion