title: Boolean indexing array through array of boolean indexes without loop
body: <p>I want to index an array with a boolean mask through multiple boolean arrays without a loop.</p>
  
  <p>This is what I want to achieve but without a loop and only with numpy.</p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  a = np.array([[0, 1],[2, 3]])
  b = np.array([[[1, 0], [1, 0]], [[0, 0], [1, 1]]], dtype=bool)
  
  r = []
  for x in b:
      print(a[x])
      r.extend(a[x])
  
  # =&gt; array([0, 2])
  # =&gt; array([2, 3])
  
  print(r)
  # =&gt; [0, 2, 2, 3]
  
  # what I would like to do is something like this
  r = some_fancy_indexing_magic_with_b_and_a
  print(r)
  # =&gt; [0, 2, 2, 3]
  </code></pre>