title: Extracting 1d arrays from 3d numpy array using 2d boolean
body: <p>Say I have a 3d numpy array:</p>
  
  <pre><code>i, j, k = 10, 3, 4
  
  arr = np.arange(120).reshape(i, j, k)
  </code></pre>
  
  <p>and a 2d boolean array:</p>
  
  <pre><code>mask = np.random.random((j, k)) &gt; 0.5
  
  n = mask.sum()
  </code></pre>
  
  <p>I want to be able to extract the 1d arrays from <code>arr</code> along its 1st dimension which correspond with the <code>True</code> values of <code>mask</code>. The result should have shape, <code>(i, n)</code>. How could this be done?</p>
  
  <p>I pulling up some old code and for some reason I was doing <code>arr[mask]</code> but this gives a shape of <code>(n, k)</code> (I'm not sure why) and a warning:</p>
  
  <pre><code>VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 10949 but corresponding boolean dimension is 11
  </code></pre>