On Fri, Nov 4, 2011 at 2:41 PM, Pauli Virtanen <[email protected]> wrote: > 04.11.2011 20:49, T J kirjoitti: > [clip] > > To push this forward a bit, can I propose that IGNORE behave as: PnC > > The *n* classes can be a bit confusing in Python: > > ### PnC > > >>> x = np.array([1, 2, 3]) > >>> y = np.array([4, 5, 6]) > >>> ignore(y[1]) > >>> z = x + y > >>> z > np.array([5, IGNORE(7), 9]) > >>> x += y # NB: x[1] := x[1] + y[1] > >>> x > np.array([5, 2, 3]) > > *** > > Interesting.
> I think I defined the "destructive" and "non-destructive" in a different > way than earlier in the thread. Maybe this behavior from np.ma is closer > to what was meant earlier: > > >>> x = np.ma.array([1, 2, 3], mask=[0, 0, 1]) > >>> y = np.ma.array([4, 5, 6], mask=[0, 1, 1]) > >>> x += y > >>> x > masked_array(data = [5 -- --], > mask = [False True True], > fill_value = 999999) > >>> x.data > array([5, 2, 3]) > > > Let's call this (since I botched and already reserved the letter "n" :) > > (m) mark-ignored > > a := SPECIAL_1 > # -> a == SPECIAL_a ; the payload of the RHS is neglected, > # the assigned value has the original LHS > # as the payload > > > Does this behave as expected for "x + y" (as opposed to the inplace operation)? >>> z = x + y >>> z np.array([5, IGNORED(2), IGNORED(3)]) >>> x += y np.array([5, IGNORED(2), IGNORED(3)]) However, doesn't this have the issue that Nathaniel brought up earlier: commutativity unignore(x + y) != unignore(y + x)
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
