title: Map function with array based on integers on 2D numpy array
body: <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; a = 0.001 * np.random.randint(0, 1000, size=(5))
  &gt;&gt;&gt; a
  array([0.524, 0.311, 0.603, 0.957, 0.923])
  
  &gt;&gt;&gt; b = np.random.randint(0, 2, size=(3, 5))
  &gt;&gt;&gt; b
  array([[1, 1, 1, 0, 1],
         [0, 0, 1, 0, 0],
         [0, 0, 1, 0, 1]])
  </code></pre>
  <p>I want to map over each row of the 2D array <code>b</code>, and if the value at row[i] == 1, set it to a[i], if the value at row[i] == 0, I want to set it to 1 - a[i].</p>
  <p>For example, for <code>b[1] = row = [0, 0, 1, 0, 0]</code>, it should become:</p>
  <pre><code>[1 - 0.524, 1 - 0.311, 0.603, 1 - 0.957, 1 - 0.923]
  </code></pre>
  <p>i.e.</p>
  <pre><code>[0.476, 0.689, 0.603, 0.043, 0.077]
  </code></pre>
  <p>How can I achieve this for all rows of the 2D matrix without resorting to for loops? (i.e. leverage efficiency of numpy)</p>