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

Gary Strangman strang at nmr.mgh.harvard.edu
Fri Nov 4 16:38:05 EDT 2011


> On Fri, Nov 4, 2011 at 1:03 PM, Gary Strangman <strang at nmr.mgh.harvard.edu>
> wrote:
>
>       To push this forward a bit, can I propose that IGNORE behave
>       as:   PnC
>
>       >>> x = np.array([1, 2, 3])
>       >>> y = np.array([10, 20, 30])
>       >>> ignore(x[2])
>       >>> x
>       [1, IGNORED(2), 3]
>       >>> x + 2
>       [3, IGNORED(4), 5]
>       >>> x + y
>       [11, IGNORED(22), 33]
>       >>> z = x.sum()
>       >>> z
>       IGNORED(6)
>       >>> unignore(z)
>       >>> z
>       6
>       >>> x.sum(skipIGNORED=True)
>       4
> 
> 
> In my mind, IGNORED items should be skipped by default (i.e., skipIGNORED
> seems redundant ... isn't that what ignoring is all about?). Thus I might
> instead suggest the opposite (default) behavior at the end:
>
>                   x = np.array([1, 2, 3])
>                   y = np.array([10, 20, 30])
>                   ignore(x[2])
>                   x
> 
> [1, IGNORED(2), 3]
>                   x + 2
> 
> [3, IGNORED(4), 5]
>                   x + y
> 
> [11, IGNORED(22), 33]
>                   z = x.sum()
>                   z
> 
> 4
>                   unignore(x).sum()
> 
> 6
>                   x.sum(keepIGNORED=True)
> 
> 6
> 
> (Obviously all the syntax is totally up for debate.)
> 
> 
> 
> I agree that it would be ideal if the default were to skip IGNORED values, but
> that behavior seems inconsistent with its propagation properties (such as when
> adding arrays with IGNORED values).  To illustrate, when we did "x+2", we were
> stating that:
> 
> IGNORED(2) + 2 == IGNORED(4)
> 
> which means that we propagated the IGNORED value.  If we were to skip them by
> default, then we'd have:
> 
> IGNORED(2) + 2 == 2
> 
> To be consistent, then it seems we also should have had:
> 
> >>> x + 2
> [3, 2, 5]
> 
> which I think we can agree is not so desirable.   What this seems to come down to
> is that we tend to want different behavior when we are doing reductions, and that
> for IGNORED data, we want it to propagate in every situation except for a
> reduction (where we want to skip over it).
> 
> I don't know if there is a well-defined way to distinguish reductions from the
> other operations.  Would it hold for generalized ufuncs?  Would it hold for other
> functions which might return arrays instead of scalars?

Ahhh, yes. That clearly explains the issue hung-up in my mind, and also 
clarifies what I was getting at with the elementwise vs. reduction 
distinction I made earlier today. Maybe this is a pickle in a jar with no 
lid. I'll have to think about it ...

-best
Gary


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.


More information about the NumPy-Discussion mailing list