[Numpy-discussion] Adding a flag to allow integer array access and masking

Travis Oliphant oliphant at ee.byu.edu
Wed Mar 6 13:01:39 CST 2002

> Like Greg I'm wary of having many different interpretations
> for indexing behavior (I'm not even that crazy about having
> numarray handle boolean index arrays differently than the others
> --something we haven't implemented yet, and perhaps we shouldn't).

You may be wary, but there are already multiple ways people think about
using integers to index arrays.  I'm trying to suggest a facility that
allows several different interpretations of array access.

> Before discussing the merits of this, shouldn't we take the attitude
> that absence of feedback is not necessarily equivalent to approval,
> particularly for something that affects the public interface of
> the module? I would feel better about this if I saw several
> affirming the need for such features rather than few openly
> opposing it.

I do have this view.  I'm not changing anything, right now.

Well, I affirm that this is one of the drawbacks of Numeric as compared
with other array-oriented environments.  We definitely need a way to index
an array using integers and masks.

I guess if nobody else feels this way, then I'm alone in my discomfort.

> But if one were to do something like this, I would use a different kind
> of object than 0d arrays, e.g., an instance of a class defined for just
> that purpose.

We could do that as well.

> You would really want to make sure that no data could
> mistakenly be interpreted as a flag, even if the chances were remote.
> I would also not use an underscore as the beginning of the name.

I'm not particularly wedded to _I notation, it was just a start.

> Maybe
> I'm wrong about this, but I've come to take that to mean its a private
> variable that should not be used by users of the module, and that usage
> would confuse that. Finally, the name of the flag should be descriptive
> (e.g. MaskInd).
> But there could be better alternatives. As an example,
> x[nonzero(maskarray)] instead of x[maskarray, MaskInd]

I've thought about that, too, it would work if nonzero returned some class
that stored away (but didn't copy) the maskarray info.


More information about the Numpy-discussion mailing list