[Numpy-discussion] Bug in dstack?
josef.pktd@gmai...
josef.pktd@gmai...
Thu Apr 2 18:50:26 CDT 2009
On Thu, Apr 2, 2009 at 6:46 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
> Note:
>
> In [133]: l = [[1,0,0],[1,1,0],[1,1,1]]
>
> In [134]: dstack(l)
> Out[134]:
> array([[[1, 1, 1],
> [0, 1, 1],
> [0, 0, 1]]])
>
> In [135]: dstack(l).shape
> Out[135]: (1, 3, 3)
>
>
> Shouldn't the shape be (3,3)? Also, for generalized ufuncs and broadcasting
> I think a function that stacked along the first axis instead of the last
> would be useful. Maybe gstack or astack?
>
> Chuck
>
I think dstack, vstack and hstack work exactly as advertised in the
docs, at least that's how I interpret and use them
Josef
>>> l = [[1,0,0],[1,1,0],[1,1,1]]
>>> np.dstack(l).shape
(1, 3, 3)
>>> np.vstack(l).shape
(3, 3)
>>> np.hstack(l).shape
(9,)
>>> np.vstack(l)
array([[1, 0, 0],
[1, 1, 0],
[1, 1, 1]])
>>> np.dstack(l)[:,:,0]
array([[1, 0, 0]])
>>> np.dstack(l)[:,:,1]
array([[1, 1, 0]])
>>> np.dstack(l)[:,:,2]
array([[1, 1, 1]])
More information about the Numpy-discussion
mailing list