<div class="gmail_quote">On Fri, Nov 4, 2011 at 2:41 PM, Pauli Virtanen <span dir="ltr"><<a href="mailto:pav@iki.fi">pav@iki.fi</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;">
04.11.2011 20:49, T J kirjoitti:<br>
[clip]<br>
<div class="im">> To push this forward a bit, can I propose that IGNORE behave as:   PnC<br>
<br>
</div>The *n* classes can be a bit confusing in Python:<br>
<br>
### PnC<br>
<div class="im"><br>
 >>> x = np.array([1, 2, 3])<br>
</div> >>> y = np.array([4, 5, 6])<br>
 >>> ignore(y[1])<br>
 >>> z = x + y<br>
 >>> z<br>
np.array([5, IGNORE(7), 9])<br>
 >>> x += y             # NB: x[1] := x[1] + y[1]<br>
 >>> x<br>
np.array([5, 2, 3])<br>
<br>
     ***<br>
<br></blockquote><div><br>Interesting.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I think I defined the "destructive" and "non-destructive" in a different<br>
way than earlier in the thread. Maybe this behavior from <a href="http://np.ma" target="_blank">np.ma</a> is closer<br>
to what was meant earlier:<br>
<br>
 >>> x = np.ma.array([1, 2, 3], mask=[0, 0, 1])<br>
 >>> y = np.ma.array([4, 5, 6], mask=[0, 1, 1])<br>
 >>> x += y<br>
 >>> x<br>
masked_array(data = [5 -- --],<br>
              mask = [False  True  True],<br>
        fill_value = 999999)<br>
 >>> x.data<br>
array([5, 2, 3])<br>
<br>
<br>
Let's call this (since I botched and already reserved the letter "n" :)<br>
<br>
(m) mark-ignored<br>
<br>
a := SPECIAL_1<br>
# -> a == SPECIAL_a ; the payload of the RHS is neglected,<br>
#                     the assigned value has the original LHS<br>
#                     as the payload<br>
<font color="#888888"><br>
<br></font></blockquote><div><br>Does this behave as expected for "x + y" (as opposed to the inplace operation)?<br><br> >>> z = x + y<br>>>> z<br>np.array([5, IGNORED(2), IGNORED(3)])<br>>>> x += y<br>
np.array([5, IGNORED(2), IGNORED(3)])<br><br>However, doesn't this have the issue that Nathaniel brought up earlier: commutativity<br><br>unignore(x + y) != unignore(y + x)<br></div></div><br>