[SciPy-User] all() and any() with array-like input

Skipper Seabold jsseabold@gmail....
Sun Jan 31 22:39:21 CST 2010

I'm sure this has come up before, but it's difficult to search of any
and all...  This is tripping me up, but maybe there is just something
I am missing.

In [1]: import numpy as np

In [2]: X = [.2,.2,.2,.2,.2]

In [3]: np.all(X <= 1)
Out[3]: False

In [4]: np.all(X >= 0)
Out[4]: True

In [5]: np.all(np.asarray(X) <= 1)
Out[5]: True

In [6]: np.any(X>1)
Out[6]: True

I guess it's simple enough to use asarray, but I was just curious what
drives this behavior since the docs indicate that it should work with
array-like structures.


More information about the SciPy-User mailing list