An alternative to np.vstack is np.array used this way (also mentioned by @bluenote10 in a comment):
x = np.arange([-3,4]) # array([-3, -2, -1, 0, 1, 2, 3])
N = 3 # number of time you want the array repeated
X0 = np.array([x] * N)
gives:
array([[-3, -2, -1, 0, 1, 2, 3],
[-3, -2, -1, 0, 1, 2, 3],
[-3, -2, -1, 0, 1, 2, 3]])
You can also use meshgrid this way (granted it's longer to write, and kind of pulling hairs but you get yet another possibility and you may learn something new along the way):
X1,_ = np.meshgrid(a,np.empty([N]))
>>> X1 shows:
array([[-3, -2, -1, 0, 1, 2, 3],
[-3, -2, -1, 0, 1, 2, 3],
[-3, -2, -1, 0, 1, 2, 3]])
Checking that all these are equivalent:
result:
array([[ True, True, True, True, True, True, True],
[ True, True, True, True, True, True, True],
[ True, True, True, True, True, True, True]])
result:
array([[ True, True, True, True, True, True, True],
[ True, True, True, True, True, True, True],
[ True, True, True, True, True, True, True]])
result:
array([[ True, True, True, True, True, True, True],
[ True, True, True, True, True, True, True],
[ True, True, True, True, True, True, True]])
tile(X,N)will do it.tileandrepmatand the like.numpybroadcasts it for you. In fact you could use that to expand the array:X + np.zeros(N).