[Numpy-discussion] question about nonzero behavior in numarray
perry at stsci.edu
Thu Apr 1 14:38:21 CST 2004
Todd pointed out to me that he's gotten some complaints about
the difference in how numarray nonzero behavior works.
In version 0.9 the use of an array for a truth value was
changed from a deprecation warning to an exception.
We deprecated it because the meaning of an array as a truth
value was ambiguous (or potentially confusing at best)
and we felt it was better to force users to be explicit
about what they wanted. Nevertheless, Numeric does allow that
and removing the capability to use it in that context breaks
We can give some thought to reversing that decision, but since
we only hear from those that don't like the new behavior, we'd
like to get some sense if there are many that do like the new
To clarify, what happens when:
x = zeros(2)
I see 3 possibilities:
1) Keep it the way it is, no use of an array is permitted; an
exception is raised.
2) Print a warning message when it is used that way, and always
keep it at that, i.e., warning message only.
3) Replicate Numeric behavior.
Personally, I prefer 1) since I think there is too much confusion
between whether false means an empty (len=0) array (like lists),
or an array that contains all zeros, and that it is worth breaking
backward compatibility on this (functions should be used to
distinguish which meaning is desired).
[Option 2 on the previous question wins hands down]
More information about the Numpy-discussion