[SciPy-dev] Arrays as truth values?
oliphant at ee.byu.edu
Mon Nov 7 21:27:55 CST 2005
Steven H. Rogers wrote:
>OK. I can't think of a really good use case for using an array as a truth
>value. I would argue though, that it would make sense for an array of zeros
>to be False and an array with any non-zero values to be True.
I agree this makes sense. That's why it used to be the default
behavior. But you can already get that behavior with any(a).
There will be many though, I'm afraid, who think b or a ought to return
element-wise like b | a does. This is not possible in Python. Raising
an error will at least alert them to the problem which might otherwise
give them misleading results.
More information about the Scipy-dev