Is there a way to get a list or array of all indices in an N-dimensional array in a fast and efficient way in Python?
For example, image we have the following array:
import numpy as np
test = np.zeros((4,4))
array([[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.]])
I would like to get all element indices as follows:
indices = [ [0,0],[0,1],[0,2] ... [3,2],[3,3] ]