I have a 2D numpy array
import numpy as np
np.array([[1, 2], [3, 4]])
[[1 2]
[3 4]]
I would like the above array to be enlarged to the following:
np.array([[1, 1, 2, 2], [1, 1, 2, 2], [3, 3, 4, 4], [3, 3, 4, 4]])
[[1 1 2 2]
[1 1 2 2]
[3 3 4 4]
[3 3 4 4]]
Each element in the original array because a 2x2 array in the new array.
I do I go from the first array to the second 'enlarged' array?
Edit
This is different from the question about scaling here How to "scale" a numpy array? because np.kron(a, np.ones((2,2)))
is not the same as a.repeat(2, axis=1).repeat(2, axis=0)
Edit #2 still waiting to get the [duplicate] flag removed
As posted by @Michael Szczesny. The numpy API has seen a slight change. This question is relevant as updated answers are being provide.