1 Feb 05:39
all() and any() with array-like input
Skipper Seabold <jsseabold <at> gmail.com>
2010-02-01 04:39:21 GMT
2010-02-01 04:39:21 GMT
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. Skipper
RSS Feed