Relatively recently, numpy.pad was introduced, so also:
>>> X = np.ones((3,2)) >>> Y = np.ones((5,2))*2 >>> N = 5 >>> nX, nY = [np.pad(m, ((0,Nm.shape[0]),(0,0)), 'constant') for m in [X, Y]] >>> nX array([[ 1., 1.], [ 1., 1.], [ 1., 1.], [ 0., 0.], [ 0., 0.]]) >>> nY array([[ 2., 2.], [ 2., 2.], [ 2., 2.], [ 2., 2.], [ 2., 2.]])
source share