I'm doing a substitute of itertools.product
as an exercise and my approach is to use np.broadcast
:
import numpy as np
x = np.array([4,3,1])
y = np.array([2,4,0])
z = np.array([0,1,2])
ix = np.broadcast(x[:,None,None], y[None,:,None], z[None, None, :])
print(*ix)
It works OK for this time but how to create all these 'eyed-arranged` new axis in an automatic way if I want, say 7 dimensions like this:
[:,None,None,None,None,None,None]
[None,:,None,None,None,None,None]
[None,None,:,None,None,None,None]
[None,None,None,:,None,None,None]
[None,None,None,None,:,None,None]
[None,None,None,None,None,:,None]
[None,None,None,None,None,None,:]
I expect something like np.ix_ that allows to use all these None
s and :
s in assignment of these slices.