[Numpy-discussion] Stacking arrays along new dimension in front
Tue Jul 20 09:49:57 CDT 2010
On Tue, Jul 20, 2010 at 10:35 AM, 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 arrays:
> In : b = np.arange(100).reshape((10, 10))
> In : a = [b, b, b]
> In : np.all(np.vstack(a) == np.concatenate([a_[None] for a_ in a]))
> Out: False
Hmm, yeah, wouldn't work without reshaping.
works, but isn't going to win you any speed contests.
More information about the NumPy-Discussion