title: Numpy fancy indexing and assignment
body: <p>Normally numpy forces the left and right side of an assignment to match, so for example if I do <code>a[:] = b</code>, <code>b</code> must be the same shape or broadcast to the same shape as <code>a</code>. But there seems to be an exception to that rule:</p>
  
  <pre><code>&gt;&gt;&gt; a = np.arange(10)
  &gt;&gt;&gt; a
  array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
  &gt;&gt;&gt; b = a.copy()
  &gt;&gt;&gt; a[[0,1,2]] = b[::2]
  &gt;&gt;&gt; a
  array([0, 2, 4, 3, 4, 5, 6, 7, 8, 9])
  &gt;&gt;&gt; a[np.arange(10)] = b[:2]
  &gt;&gt;&gt; a
  array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1])
  </code></pre>
  
  <p>It seems to only work with 1d arrays and only if there is fancy indexing on the left side of the assignment, but I haven't been able to find documentation for this behavior anywhere. Is this behavior documented, if so where, and also can someone give an example of when it might be useful?</p>
  
  <p>Update:</p>
  
  <p>It seems that the numpy flatiter type behaves this way too, is there some connection between flatiter and fancy indexing that I don't know about?</p>
  
  <pre><code>&gt;&gt;&gt; a.flat = [10,11]
  &gt;&gt;&gt; a
  array([10, 11, 10, 11, 10, 11, 10, 11, 10, 11])
  &gt;&gt;&gt; a.flat[:] = [2,3,4]
  &gt;&gt;&gt; a
  array([2, 3, 4, 2, 3, 4, 2, 3, 4, 2])
  &gt;&gt;&gt; a.flat = range(100)
  &gt;&gt;&gt; a
  array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
  </code></pre>