Numpy: how I can determine if all elements of numpy array are equal to a number
<p>I need to know if all the elements of an array of <code>numpy</code> are equal to a number</p>

<p>It would be like:</p>

<pre><code>numbers = np.zeros(5) # array[0,0,0,0,0]
print numbers.allEqual(0) # return True because all elements are 0
</code></pre>

<p>I can make an algorithm but, there is some method implemented in <code>numpy</code> library?</p>

<p>You can break that down into <code>np.all()</code>, which takes a boolean array and checks it's all <code>True</code>, and an equality comparison:</p>

<pre><code>np.all(numbers == 0)
# or equivalently
(numbers == 0).all()
</code></pre>

python arrays numpy