[Numpy-discussion] Addition of masked and indexed arrays.

Travis Oliphant oliphant at ee.byu.edu
Tue Feb 26 17:08:15 EST 2002


I'm proposing the addition of the following semantics to Numeric Arrays in
order to support indexing arrays using mask and index arrays.  Notice that
the change required to support this behavior is minimal and all the work
can be backloaded to the user.

Let the array_subscript C code check to see if the index object passed in
is a Tuple with the last element being a callable method.  If this is the
case, then the C code calls the callable method to handle the array
assignment or array indexing code.

So, for example  one might say.

a[a<3,mask] = 10

where mask is a callable method (or Cobject) which does effectively but
has the right calling convention.

putmask(a, a<3, 10).

This same semantics could also handle integer indexing of arrays (using
multiple styles).  All that's required is a simple test in Numeric that
does not break any current code.

What do you think?  Could I add the necessary check to support this in
Numeric?  Do others have a better idea?

I know numarray is the solution to all of our problems.  But, something
tells me that the current version of Numeric is going to be around for a
little while and it would be nice for it to have some of these useful
features.

-Travis






More information about the NumPy-Discussion mailing list