The Python code
import numpy as np
def mesh(l):
g = np.array(np.meshgrid(*l))
return np.moveaxis(g, 0, -1)
mesh([[1,2],[3,4],[5,6]])
gives the output
array([[[[1, 3, 5],
[1, 3, 6]],
[[2, 3, 5],
[2, 3, 6]]],
[[[1, 4, 5],
[1, 4, 6]],
[[2, 4, 5],
[2, 4, 6]]]])
Why is the third and then the first index changing? I expected it to look like
- [1, 3, 5]
- [1, 3, 6]
- [1, 4, 5]
- etc.