title: Does assignment with advanced indexing copy array data?
body: <p>I am slowly trying to understand the difference between <code>view</code>s and <code>copy</code>s in numpy, as well as mutable vs. immutable types.</p>
  
  <p>If I access part of an array with <a href="http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#advanced-indexing">'advanced indexing'</a> it is supposed to return a copy.  This seems to be true:</p>
  
  
  
  <pre><code>In [1]: import numpy as np
  In [2]: a = np.zeros((3,3))
  In [3]: b = np.array(np.identity(3), dtype=bool)
  
  In [4]: c = a[b]
  
  In [5]: c[:] = 9
  
  In [6]: a
  Out[6]: 
  array([[ 0.,  0.,  0.],
         [ 0.,  0.,  0.],
         [ 0.,  0.,  0.]])
  </code></pre>
  
  <p>Since <code>c</code> is just a copy, it does not share data and changing it does not mutate <code>a</code>.  However, this is what confuses me:</p>
  
  
  
  <pre><code>In [7]: a[b] = 1
  
  In [8]: a
  Out[8]: 
  array([[ 1.,  0.,  0.],
         [ 0.,  1.,  0.],
         [ 0.,  0.,  1.]])
  </code></pre>
  
  <p>So, it seems, even if I use advanced indexing, assignment still treats the thing on the left as a view.  Clearly the <code>a</code> in line 2 is the same object/data as the <code>a</code> in line 6, since mutating <code>c</code> has no effect on it.</p>
  
  <p>So my question: is the <code>a</code> in line 8 the same object/data as before (not counting the diagonal of course) or is it a copy?  In other words, was <code>a</code>'s data copied to the new <code>a</code>, or was its data mutated in place?</p>
  
  <p>For example, is it like:</p>
  
  <pre><code>x = [1,2,3]
  x += [4]
  </code></pre>
  
  <p>or like:</p>
  
  <pre><code>y = (1,2,3)
  y += (4,)
  </code></pre>
  
  <p>I don't know how to check for this because in either case, <code>a.flags.owndata</code> is <code>True</code>.  Please feel free to elaborate or answer a different question if I'm thinking about this in a confusing way.</p>