title: replace numpy array elements with a value between 0 and 1
body: <p>I've got a very simple task and numpy is doing something I don't understand. I'm trying to replace elements of an array that meet some criteria with a number between 0 and 1, and numpy is converting them all into zeroes. For example:</p>
  
  <pre><code>In [1]: some_array = np.array([0,0,0,1,0,1,1,1,0])
  
  In [2]: nonzero_idxs = np.where(some_array != 0)[0]
  
  In [3]: nonzero_idxs
  Out[3]: array([3, 5, 6, 7])
  
  In [4]: some_array[nonzero_idxs] = 99
  
  In [5]: some_array
  Out[5]: array([ 0,  0,  0, 99,  0, 99, 99, 99,  0])
  
  In [6]: some_array[nonzero_idxs] = 0.2
  
  In [7]: some_array[nonzero_idxs]
  Out[7]: array([0, 0, 0, 0])
  
  In [8]: some_array[nonzero_idxs] == 0
  Out[8]: array([ True,  True,  True,  True], dtype=bool)
  </code></pre>
  
  <p>As the example above shows, replacing values with some arbitrary value works as expected, but if you try to replace it with a decimal, it turns it into a zero (and they don't just <em>look</em> like zeros when you print the array, they're evaluating as equal to zero). The same behavior happens when I try to go about this in other ways, for example, by using np.place.</p>
  
  <p>I'm doing this within iPython on the terminal, if that makes any difference. Can someone explain what's happening here, and how to avoid it? Apologies if this is a duplicate.</p>