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

Gary Strangman strang@nmr.mgh.harvard....
Fri Nov 4 15:03:02 CDT 2011


> > NAN and NA apparently fall into the PdS class.
> >
> 
> Here is where I think we need ot be a bit more careful.  It is true that we want
> NAN and MISSING to propagate, but then we additionally want to ignore it
> sometimes.  This is precisely why we have functions like nansum.  Although people
> are well-aware of this desire, I think this thread has largely conflated the
> issues when discussing "propagation".
> 
> 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
> 
> When done in this fashion, I think it is perfectly fine for "masks to be
> unmasked".

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.)

-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