Suppose I have a 3 dimensional array of zeros
Y = np.zeros((2,3,4))
and I wished to broadcast a 1 dimensional array to it via the second dimension
X = np.arange(3)
such that the resulting multidimensional array was
Y = [[[ 0. 0. 0. 0.]
[ 1. 1. 1. 1.]
[ 2. 2. 2. 2.]]
[[ 0. 0. 0. 0.]
[ 1. 1. 1. 1.]
[ 2. 2. 2. 2.]]]
What would be the most pythonic and efficient way of achieving this without loops (or even list comprehensions)? I wish to be able to scale this up with larger dimension sizes and run the code with the numba module, which does not compile with np.tile or np.repeat