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

2010-07-20 Thread Skipper Seabold
On Tue, Jul 20, 2010 at 10:35 AM, Gael Varoquaux wrote: > 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.conca

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

2010-07-20 Thread Gael Varoquaux
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 arra

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

2010-07-20 Thread Keith Goodman
On Tue, Jul 20, 2010 at 7:24 AM, Skipper Seabold wrote: > On Tue, Jul 20, 2010 at 5:11 AM, Gael Varoquaux > wrote: >> Is there in numpy a function that does: >> >>    np.concatenate([a_[np.newaxis] for a_ in a]) >> >> ? >> >> ie: add a dimension in front and stack along this dimension, just like

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

2010-07-20 Thread Skipper Seabold
On Tue, Jul 20, 2010 at 5:11 AM, Gael Varoquaux wrote: > Is there in numpy a function that does: > >    np.concatenate([a_[np.newaxis] for a_ in a]) > > ? > > ie: add a dimension in front and stack along this dimension, just like > >    np.array(a) > > would do, but more efficient. > > This is som

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

2010-07-20 Thread Gael Varoquaux
Is there in numpy a function that does: np.concatenate([a_[np.newaxis] for a_ in a]) ? ie: add a dimension in front and stack along this dimension, just like np.array(a) would do, but more efficient. This is something that do all the time. Am I the only one? Cheers, Gaël __