Reputation: 120
I have a discretized 8-dimensional bounded space for which I want to get a grid over all possible combinations in a shape of (N,8). It should look like:
import numpy as np
myGrid = np.array([[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,2],...])
The bounds of all 8 dimensions are not equal.
Upvotes: 0
Views: 212
Reputation: 53029
You can use indices
and moveaxis
:
np.moveaxis(np.indices(<your shape>), 0, -1).reshape(-1, 8)
This will be zero-based, so add 1 to get exactly your desired output.
Upvotes: 1