[Numpy-discussion] in the NA discussion, what can we agree on?

Nathaniel Smith njs at pobox.com
Sat Nov 5 03:55:13 EDT 2011


On Fri, Nov 4, 2011 at 8:33 PM, T J <tjhnson at gmail.com> wrote:
> On Fri, Nov 4, 2011 at 8:03 PM, Nathaniel Smith <njs at pobox.com> wrote:
>> Again, I really don't think you're going to be able to sell an API where
>>  [2] + [IGNORED(20)] == [IGNORED(22)]
>> I mean, it's not me you have to convince, it's Gary, Pierre, maybe
>> Benjamin, Lluís, etc. So I could be wrong. But you might want to
>> figure that out first before making plans based on this...
>
> But this is how np.ma currently does it, except that it doesn't compute the
> payload---it just calls it IGNORED.

Yes, that's what I mean -- if you're just temporarily masking
something out because you want it to be IGNORED, then you don't want
it to change around when you do something like a += 2, right? If the
operation is changing the payload, then it's weird to say that the
operation ignored the payload...

Anyway, I think this is another way to think about your suggestion:

-- each array gets an extra boolean array called the "mask" that it
carries around with it
-- Unary ufuncs automatically copy these masks to their results. For
binary ufuncs, the input masks get automatically ORed together, and
that determines the mask attached to the output array
-- these masks have absolutely no effect on any computations, except that
     ufunc.reduce(a, skip_IGNORED=True)
is defined to be a synonym for
     ufunc.reduce(a, where=a.mask)

Is that correct?

Also, if can I ask -- is this something you would find useful yourself?

-- Nathaniel



More information about the NumPy-Discussion mailing list