title: Python: "Use a.any() or a.all()" while traversing a numpy.ndarray
body: <p>In a <code>numpy.ndarray</code> like this one:</p>
  
  <pre><code>myarray=
  array([[ 0.47174344,  0.45314669,  0.46395022,  0.47440382,  0.50709627,
           0.53350065,  0.5233444 ,  0.49974663,  0.48721607,  0.46239652,
           0.4693633 ,  0.47263569,  0.47591957,  0.436558  ,  0.43335574,
           0.44053621,  0.42814804,  0.43201894,  0.43973886,  0.44125302,
           0.41176999],
         [ 0.46509004,  0.46221505,  0.48824086,  0.50088744,  0.53040384,
           0.53592231,  0.49710228,  0.49821022,  0.47720381,  0.49096272,
           0.50438366,  0.47173162,  0.48813669,  0.45032002,  0.44776794,
           0.43910269,  0.43326132,  0.42064458,  0.43472954,  0.45577299,
           0.43604956]])
  </code></pre>
  
  <p>I want to count how many cells exceed a given value, let's say <code>0.5</code>, and set those that don't to <code>0.0</code>. This is what I do:</p>
  
  <pre><code>count=0 
  value=0.5
  for i in range(myarray.shape[0]):
     for j in range(myarray.shape[1]):
         if myarray[i][j]&lt;value:
            myarray[i][j]=0 
         elif myarray[i][j]&gt;=value:     
            count=count+1 
  percentage=round(100*count/(myarray.shape[0]*myarray.shape[1]),2)
  </code></pre>
  
  <p>However, I get this error: <code>ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()</code>, pointing at the line where I check <code>if myarray[i][j]&lt;value</code>. </p>
  
  <p><strong>Why does this happen and how to fix it?</strong> What is the truth value?</p>