I have written a simple function which iterates over a numpy array with some fixed indices.
def compute_V(i,j,nA, nB,V):
Vijkl = np.zeros((i,j,nA,nB))
for k in range(nA):
for l in range(nB):
Vijkl[i,j,k,l] = V[i,j,k,l] + 3
return Vijkl
I am getting the following error back: IndexError: index 1 is out of bounds for axis 0 with size 1
What am I doing wrong?
The matrix V has a shape: (1, 2, 1, 2) and looks:
[[[[-0.00009 -0.00001]]
[[-0.00001 -0.00001]]]]
i = 0, j = 0, nA = 1, nB = 2
Looks the loop goes over one iteration:
i,j,k,l,V: 0 0 0 0 -9.39073120245e-05
then throws the error.