title: Convert numpy matrix into 1D numpy array
body: <p>I have the sum of a <code>csr_matrix</code> over one dimension, which returns a 1 dimensional vector. This is by default of the type <code>numpy.matrix</code> with shape (1, N). However, I want to represent this by a <code>numpy.array</code> with shape (N,). The following works:</p>
  
  <pre><code>&gt;&gt;&gt; import numpy as np; import scipy.sparse as sparse
  &gt;&gt;&gt; a = sparse.csr_matrix([[0,1,0,0],[1,0,0,0],[0,1,2,0]])
  &gt;&gt;&gt; a
  Out[15]: 
  &lt;3x4 sparse matrix of type '&lt;class 'numpy.int64'&gt;'
      with 4 stored elements in Compressed Sparse Row format&gt;
  &gt;&gt;&gt; a.todense()
  Out[16]: 
  matrix([[0, 1, 0, 0],
          [1, 0, 0, 0],
          [0, 1, 2, 0]], dtype=int64)
  &gt;&gt;&gt; a.sum(axis=0)
  Out[17]: matrix([[1, 2, 2, 0]], dtype=int64)
  &gt;&gt;&gt; np.array(a.sum(axis=0)).ravel()
  Out[18]: array([1, 2, 2, 0], dtype=int64)
  </code></pre>
  
  <p>However, this last step seems a bit overkill for a transformation from a numpy matrix to numpy array. Is there a function that I am missing that can do this for me? It shall pass the following unit test.</p>
  
  <pre><code>def test_conversion(self):
      a = sparse.csr_matrix([[0,1,0,0],[1,0,0,0],[0,1,2,0]])
      r = a.sum(axis=0)
      e = np.array([1, 2, 2, 0])
      np.testing.assert_array_equal(r, e)
  </code></pre>