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

Pauli Virtanen pav at iki.fi
Sat Nov 5 06:57:58 EDT 2011


05.11.2011 03:43, T J kirjoitti:
> I thought that "PdC" satisfied (a) and (b).
> Let me show you what I thought they were. Perhaps I am not being
> consistent. If so, point out my mistake.

Yes, propagating + destructive assigment + do-computations-on-payload 
should satisfy (a) and (b). (NA also works as it's a singleton.)

The question is now that are there other rules, with more desirable 
behavior of masked values, that also have

	a += b
	a += 42
	print unmask(a)


	a += 42
	a += b
	print unmask(a)

as equivalent operations.

The rules chosen by np.ma don't satisfy this. If taking a commutative 
version of np.ma's binary op rules, it seems that it's not clear how to 
make assignment work exactly in the way you'd expect of masked values 
while retaining equivalence in the above code.

It seems that having `a += b` have `a[j]` unchanged if it's ignored, and 
having ignored values propagate creates the problem.

Pauli Virtanen

More information about the NumPy-Discussion mailing list