title: Numpy: shuffle subset of elements
body: <p>I have a 2-D numpy-array, interpreting it as a grid, and want to permute a subset of the elements.
  More precisely, an edge shall be mapped to an edge and a corner mapped to a corner.</p>
  
  <ul>
  <li><code>np.random.shuffle</code> does the job, when any permutation of elements is fine.</li>
  </ul>
  
  <p>I can access the corners by:</p>
  
  <pre><code>a = np.arange(16).reshape((4,4))
  a[[0,0,-1,-1],[0,-1,0,-1]]
  </code></pre>
  
  <p>However, when I call</p>
  
  <pre><code>np.random.shuffle(a[[0,0,-1,-1],[0,-1,0,-1]])
  </code></pre>
  
  <p>the array is not changed. Reading <a href="https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html" rel="nofollow noreferrer">https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html</a>, I found out that the above used <strong>Advanced Slicing</strong>, which returns a copy, instead of a view.
  But this copy is shuffled in-place, so there is no result to be assigned to the original array.</p>
  
  <p>So the questions is, how can I permute the elements of the chosen indices?</p>