title: How to replace all elements of Python NumPy Array that are greater than a several values?
body: <p>I know that I can replace all elements of Python NumPy Array that are greater than some value:</p>
  
  <pre><code>np.putmask(A, A&gt;0.5, 5)
  </code></pre>
  
  <p>Where <code>A&gt;0.5</code> is the threshold and 5 the new replacement. However, how can I do it for more conditions? for example for:</p>
  
  <pre><code>if x.all &lt;0:
      return 00.1
  elif x.all &gt;0:
      return 1
  </code></pre>
  
  <p>Where x is an array. I tried to:</p>
  
  <pre><code>np.putmask(x, x&lt;0, 00.1)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>np.putmask(x, x&gt;0, 1)
  </code></pre>
  
  <p>However, I would like to do it in a single line. Any idea of how to do this type of replacements in just a single line with putmask or any other method?</p>