title: How do I consistently flatten a numpy array?
body: <pre><code>from numpy import array, eye, matrix
  
  x = array([1, 0])
  A = eye(2)
  print(A.dot(x))
  </code></pre>
  
  <p>prints <code>[1. 0.]</code>. </p>
  
  <p>On the other hand,</p>
  
  <pre><code>B = matrix([[1, 0], [0, 1]])
  print(B.dot(x))
  </code></pre>
  
  <p>prints <code>[[1 0]]</code> which is a 1-by-2 array. Furthermore,</p>
  
  <pre><code>print(B.dot(x).flatten())
  </code></pre>
  
  <p>also prints <code>[[1 0]]</code>.</p>
  
  <p>This is rather annoying. Why does flatten fail here and how else can I get this into the 1-d shape?</p>