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

Pauli Virtanen pav@iki...
Fri Nov 4 20:31:46 CDT 2011


05.11.2011 00:14, T J kirjoitti:
[clip]
>      a = 1
>      a += 2
>      a += IGNORE
>      b = 1 + 2 + IGNORE
>
> I think having a == b is essential.  If they can be different, that will
> only lead to confusion.  On this point alone, does anyone think it is
> acceptable to have a != b?

It seems to me that requiring this sort of a thing gives some 
limitations on how array operations should behave.

An acid test for proposed rules: given two arrays `a` and `b`,

         a = [1, 2, IGNORED(3), IGNORED(4)]
	b = [10, IGNORED(20), 30, IGNORED(40)]

(a) Are the following pieces of code equivalent:

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

     and

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

(b) Are the following two statements equivalent (wrt. ignored values):

	a += b
	a[:] = a + b

For np.ma (a) is false whereas (b) is true. For arrays containing nans, 
on the other hand (a) and (b) are both true (but of course, in this case 
values cannot be unmasked).

Is there a way to define operations so that (a) is true, while retaining 
the desired other properties of arrays with ignored values?

Is there a real-word need to have (a) be true?

-- 
Pauli Virtanen



More information about the NumPy-Discussion mailing list