[Numpy-discussion] Stacking arrays along new dimension in front

Gael Varoquaux gael.varoquaux@normalesup....
Tue Jul 20 09:35:49 CDT 2010


On Tue, Jul 20, 2010 at 10:24:56AM -0400, Skipper Seabold wrote:
> Will one of the stack functions do?  I take it your a looks something like

> a = [np.arange(1000), np.arange(1000), np.arange(1000)]

> np.all(np.vstack(a) == np.concatenate([a_[None] for a_ in a]))
> # True

Works only for 1D arrays:

In [3]: b = np.arange(100).reshape((10, 10))

In [4]: a = [b, b, b]

In [5]: np.all(np.vstack(a) == np.concatenate([a_[None] for a_ in a]))
Out[5]: False

Gaël


More information about the NumPy-Discussion mailing list