title: Adding arrays with different number of dimensions
body: <p>Let's say I have a 2D Numpy array:</p>
  
  <pre><code>&gt;&gt;&gt; a = np.random.random((4,6))
  </code></pre>
  
  <p>and I want to add a 1D array to each row:</p>
  
  <pre><code>&gt;&gt;&gt; c = np.random.random((6,))
  &gt;&gt;&gt; a + c
  </code></pre>
  
  <p>This works. Now if I try adding a 1D array to each column, I get an error:</p>
  
  <pre><code>&gt;&gt;&gt; b = np.random.random((4,))
  &gt;&gt;&gt; a + b
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ValueError: shape mismatch: objects cannot be broadcast to a single shape
  </code></pre>
  
  <p>I can fix this by using <code>np.newaxis</code>:</p>
  
  <pre><code>&gt;&gt;&gt; a + b[:,np.newaxis]
  </code></pre>
  
  <p>which does work as expected.</p>
  
  <p>What are the shape-matching rules to avoid having to use np.newaxis? Is it that the last element of the numpy shape tuple has to match? Does this rule also apply to higher dimensions? For example, the following works:</p>
  
  <pre><code>&gt;&gt;&gt; a = np.random.random((2,3,4,5))
  &gt;&gt;&gt; b = np.random.random((4,5))
  &gt;&gt;&gt; a + b
  </code></pre>
  
  <p>So my question is whether this is documented anywhere, and if it is a behavior that can be relied on, or whether it is best to always use np.newaxis?</p>