I'm trying to convert my code to Numba friendly implementation, however I keep running into errors with the axis argument (as it is not supported). Specifically, I need to use the np.repeat() function in axis=2, or more generally how to repeat the array along the last dimension.
In numpy my code is:
original = np.random.rand(1000,1)
no_repeats = 10
big_original = np.repeat(np.expand_dims((5)*original, axis=2), no_repeats, axis=2)
How could I rewrite this in a Numba friendly way?
I have tried to use np.dstack:
expanded_original = np.expand_dims((5)*original, axis=2)
big_original = np.dstack([expanded_original]*no_repeats)
But of course lists aren't a supported datatype. How could I go about this in the most efficient way?
I don't know what are you exactly trying to do but I guess you want to reproduce the
big_originalarray inside a@njitnumba compiled function. Right?I so:
If this is not the answer you were expecting, please try to better specify your problem (e.g. what
expandedGradientMatrixis) and your expected output.