Consider the following small example, dramatically simplified compared to my actual use case:
import numpy as np
z = np.arange(125).reshape(5,5,5)
i = np.where( np.mod(z[0], 3) == 0 )
So that i is a tuple of 2 arrays.
Now I can use i to index into a slice of z
z[0][i]
# array([ 0, 3, 6, 9, 12, 15, 18, 21, 24])
z[1][i]
# array([25, 28, 31, 34, 37, 40, 43, 46, 49])
I would like to get the result of this indexing for every slice of z. So naturally I tried z[:, i]. However, z[:, i].shape is (5, 2, 9, 5), not what I would have expected, (5, 9).
Since z[:, i[0], i[1]] gives the expected result, I tried z[:, *i] but was met with a SyntaxError.
In my full example I don't necessarily know how many arrays are in i, so hard-coding like z[:, i[0], i[1]] is not possible.
Question:
Is it possible to achieve something like z[:, *i] that gives the same result as z[:, i[0], i[1], i[2], ... i[n-1]] in case i has n arrays in it?