Reputation: 113
import numpy as np
cube = np.zeros((2,2,2,2,2,2,2)) # Make 7 dim hypercube
vector=[1,0,1,1,0,1,1]
cube[vector[0],vector[1],vector[2],vector[3],vector[4],vector[5],vector[6]] # access the field [1,0,1,1,0,1,1]
I have to work with some high dimensional arrays and I would like to access their fields through variables.
The above code shows a very bad solution and I am sure that there is a more efficient one, something similar to cube[vector]
or cube[vector[i] for i in range(len(vector))]
but none of them seem to work.
Upvotes: 1
Views: 79