<div class="gmail_quote">On Fri, Nov 4, 2011 at 1:03 PM, Gary Strangman <span dir="ltr"><<a href="mailto:strang@nmr.mgh.harvard.edu">strang@nmr.mgh.harvard.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
To push this forward a bit, can I propose that IGNORE behave as:   PnC<br>
<br>
>>> x = np.array([1, 2, 3])<br>
>>> y = np.array([10, 20, 30])<br>
>>> ignore(x[2])<br>
>>> x<br>
[1, IGNORED(2), 3]<br>
>>> x + 2<br>
[3, IGNORED(4), 5]<br>
>>> x + y<br>
[11, IGNORED(22), 33]<br>
>>> z = x.sum()<br>
>>> z<br>
IGNORED(6)<br>
>>> unignore(z)<br>
>>> z<br>
6<br>
>>> x.sum(skipIGNORED=True)<br>
4<br>
<br>
</blockquote>
<br></div></div>
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:<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
x = np.array([1, 2, 3])<br>
y = np.array([10, 20, 30])<br>
ignore(x[2])<br>
x<br>
</blockquote></blockquote></blockquote>
[1, IGNORED(2), 3]<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
x + 2<br>
</blockquote></blockquote></blockquote>
[3, IGNORED(4), 5]<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
x + y<br>
</blockquote></blockquote></blockquote>
[11, IGNORED(22), 33]<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
z = x.sum()<br>
z<br>
</blockquote></blockquote></blockquote></div>
4<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
unignore(x).sum()<br>
</blockquote></blockquote></blockquote>
6<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
x.sum(keepIGNORED=True)<br>
</blockquote></blockquote></blockquote>
6<br>
<br>
(Obviously all the syntax is totally up for debate.)<br>
<br></blockquote></div><br><br>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:<br>
<br>IGNORED(2) + 2 == IGNORED(4)<br><br>which means that we propagated the IGNORED value.  If we were to skip them by default, then we'd have:<br><br> IGNORED(2) + 2 == 2<br><br>To be consistent, then it seems we also should have had:<br>
<br>>>> x + 2<br>[3, 2, 5]<br><br>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).<br>
<br>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?<br>