I haven\'t grokked the key concepts in numpy yet.
I would like to create a 3-dimensional array and populate each cell with the result of a function call
I think it is a little confusing that most examples of fromfunction use square arrays.
Perhaps looking at a non-square array could be helpful?
def f(x,y):
print(f'x=\n{x}')
print(f'y=\n{y}')
return x+y
z = np.fromfunction(f,(4,3))
print(f'z=\n{z}')
Results in:
x=
[[0 0 0]
[1 1 1]
[2 2 2]
[3 3 3]]
y=
[[0 1 2]
[0 1 2]
[0 1 2]
[0 1 2]]
z=
[[0 1 2]
[1 2 3]
[2 3 4]
[3 4 5]]