title: Numpy apply functions to selected indices of matrix
body: <p>I have two random index generators, from 0 to 3</p>
  
  <pre><code>idx_1 = np.random.choice(4, 2, replace=False)
  idx_2 = np.setdiff1d(range(4), idx_1)
  </code></pre>
  
  <p>and I have a 3D numpy array, example_array, made of stacking 4 matrices together, and 2 functions , say func1 and func2. </p>
  
  <p>I want to do something like</p>
  
  <pre><code>example_array[idx1[0]] = func1(example_array[idx1[0]])
  example_array[idx1[1]] = func1(example_array[idx1[1]])
  example_array[idx2[0]] = func2(example_array[idx2[0]])
  example_array[idx2[1]] = func2(example_array[idx1[0]])
  </code></pre>
  
  <p>What is a fast way of doing that, without explicitly writing them as above? </p>