You're right, they are not equivalent. vstack will happily create an array of higher rank than the parts it is stacking, whereas concatenate requires the arrays it is working with to already be at least 2d, so the equivalent is np.concatenate((np.arange(5.)[newaxis],np.arange(5.)[newaxis]), axis=0) or np.concatenate((np.atleast_2d(np.arange(5.)),np.atleast_2d(np.arange(5.))), axis=0)
Gary R. On Wed, Mar 30, 2011 at 9:30 PM, andrew nelson <andyf...@gmail.com> wrote: > Dear List, > I have a quick question regarding vstack and concatenate. > In the docs for vstack it says that: > > np.concatenate(tup, axis=0) > > should be equivalent to: > > np.vstack(tup) > > However, I tried this out and it doesn't seem to be case, i.e. > >>>> np.vstack((np.arange(5.), np.arange(5.))) > array([[ 0., 1., 2., 3., 4.], > [ 0., 1., 2., 3., 4.]]) > >>>> np.concatenate((np.arange(5.),np.arange(5.)), axis=0) > array([ 0., 1., 2., 3., 4., 0., 1., 2., 3., 4.]) > > These aren't the same. Maybe I'm missing something? > > regards, > Andrew. > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion