I'd like to do something like this:
if dim==2:
a,b=grid_shape
for i in range(a):
for j in range(b):
A[i,j] = ...things...
where dim
is simply the number of elements in my tuple grid_shape
. A
is a numpy array of dimension dim
.
Is there a way to do it without being dimension specific?
Without having to write ugly code like
if dim==2:
a,b=grid_shape
for i in range(a):
for j in range(b):
A[i,j] = ...things...
if dim==3:
a,b,c=grid_shape
for i in range(a):
for j in range(b):
for k in range(c):
A[i,j,k] = ...things...