title: numpy dot on 1D and 2D array
body: <p>I am trying to understand what happens in the following python code:</p>
  
  <pre><code>import numpy as np
  
  numberList1 = [1,2,3]
  numberList2 = [[4,5,6],[7,8,9]]
  
  result = np.dot(numberList2, numberList1)
  
  # Converting iterator to set
  resultSet = set(result)
  print(resultSet)
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>{32, 50}</p>
  </blockquote>
  
  <p>I can see that it is multiplying each element in <code>numberList1</code> by the element in the same position in each array within <code>numberList2</code> - so <code>{1*4 + 2*5 + 3*6 = 32},{1*7+2*8+3*9 = 50}</code>.</p>
  
  <p>But, if I change the arrays to:</p>
  
  <pre><code>numberList1 = [1,1,1]
  numberList2 = [[2,2,2],[3,3,3]]
  </code></pre>
  
  <p>Then the output I see is</p>
  
  <blockquote>
    <p>{9, 6}</p>
  </blockquote>
  
  <p>Which is the wrong way around...</p>
  
  <p>and, if I change it to:</p>
  
  <pre><code>numberList1 = [1,1,1]
  numberList2 = [[2,2,2],[2,2,2]]
  </code></pre>
  
  <p>Then the output I see is just </p>
  
  <blockquote>
    <p>{6}</p>
  </blockquote>
  
  <p>From the documentation:</p>
  
  <blockquote>
    <p>If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b.</p>
  </blockquote>
  
  <p>I am not enough of a mathematician to understand quite what this is telling me; or why the order of the outputs swaps around sometimes.</p>