the numpy.all function does not work. I created A = np.random.random((10,1)) np.all(A)<1 gives me False, which is wrong! and B = 2 * A np.all(B)<2 gives me True, which is correct! also np.sum(A) < 10, gives me True, which is correct!
NumPy is not part of Python's standard library, so this is a 3rd party problem. However, please don't waste the time of the NumPy developers with this. You either haven't read the documentation or have misread it. numpy.all [1] is an AND reduction over the specified dimension or all dimensions of an array. >>> import numpy as np >>> A = np.random.random((10, 1)) >>> np.all(A) True >>> True < 1 False >>> isinstance(True, int) True >>> int(True) 1 The following checks whether all values are less than 1: >>> A < 1 array([[ True], [ True], [ True], [ True], [ True], [ True], [ True], [ True], [ True], [ True]], dtype=bool) >>> np.all(A < 1) True [1]: http://docs.scipy.org/doc/numpy/reference/generated/numpy.all.html
This is not a bug, but behaving correctly. You have: py> A = np.random.random((10,1)) py> np.all(A) True py> np.all(A) < 1 # is True less than 1? False which is correct: True is *not* less than 1. But True *is* less than 2: py> True < 2 True py> np.all(2*A) True Also, for future reference, please do not post screen shoots unless you absolutely have to. Screenshots make it impossible to copy the code from your example, and make it difficult for anyone who is visually impaired and using a screen-reader to contribute. Instead, copy and paste the text from your interpreter. Thank you.