Index n dimensional array with (n-1) d array : <p>What is the most elegant way to access an n dimensional array with an (n-1) dimensional array along a given dimension as in the dummy example</p>

<pre><code>a = np.random.random_sample((3,4,4))
b = np.random.random_sample((3,4,4))
idx = np.argmax(a, axis=0)
</code></pre>

<p>How can I access now with <code>idx a</code> to get the maxima in <code>a</code> as if I had used <code>a.max(axis=0)</code>? or how to retrieve the values specified by <code>idx</code> in <code>b</code>?</p>

<p>I thought about using <code>np.meshgrid</code> but I think it is an overkill. Note that the dimension <code>axis</code> can be any usefull axis (0,1,2) and is not known in advance. Is there an elegant way to do this?</p>
