title: Concise way to get NumPy to return array of proper shape after logical indexing, without doing a reshape?
body: <p>Say I have the array:</p>
  
  <pre><code> &gt;&gt;&gt; import numpy as np
   &gt;&gt;&gt; myarr = np.array([[1],[2],[3],[2]])
  </code></pre>
  
  <p>and I want to use logical indexing to return the sub-array where <code>myarr</code> is not equal to 2.</p>
  
  <pre><code> &gt;&gt;&gt; subarr = myarr[myarr != 2]
   &gt;&gt;&gt; print subarr
   [1 3]
  </code></pre>
  
  <p>Thus, <code>myarr.shape = (4,1)</code> but <code>subarr.shape = (2,)</code>.</p>
  
  <p>Why is the size of dimension 2 being changed when the logical indexing doesn't affect dimension 2? I could easily just reshape the output, but if I need to use logical indexing often in my code, I don't want to have to always account for extra dimensions (i.e. dimensions that are obviously not relevant to the logical slice I am doing) that may have changed. </p>
  
  <p>This (N,1) --> (K,) example is especially bothersome, since any logical slice of a something-by-one array must also be a something-by-one array.</p>
  
  <p>I feel like there must be a cleaner way to have the NumPy slice operations leave trivial array dimensions alone. Any suggestions?</p>