I would like to execute the equivalent of the following MATLAB code using NumPy: repmat([1; 1], [1 1 1])
. How would I accomplish this?
>>> import numpy as np
>>> np.repeat(['a','b'], [2,5])
array(['a', 'a', 'b', 'b', 'b', 'b', 'b'], dtype='<U1')
>>> np.repeat([1,2], [2,5])
array([1, 1, 2, 2, 2, 2, 2])
>>> np.repeat(np.array([1,2]), [3]).reshape(2,3)
array([[1, 1, 1],
[2, 2, 2]])
>>> np.repeat(np.array([1,2]), [2,4]).reshape(3,2)
array([[1, 1],
[2, 2],
[2, 2]])
>>> np.repeat(np.matrix('1 2; 3 4'), [2]).reshape(4,2)
matrix([[1, 1],
[2, 2],
[3, 3],
[4, 4]])