I want a easy to read access to some parts of a multidimensional numpy array. For any array accessing the first dimension is easy (b[index]
). Accessing the sixth dimension on the other hand is "hard" (especially to read).
b[:,:,:,:,:,index] #the next person to read the code will have to count the :
Is there a better way to do this?
Especially is there a way, where the axis is not known while writing the program?
Edit:
The indexed dimension is not necessarily the last dimension
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…