[SciPy-user] shape

Ryan Krauss ryanlists at gmail.com
Thu Apr 26 15:49:09 EDT 2007


It is a 1 dimensional array, so it has only one dimension.  Numpy does
not assume everything is a 2D array the way Matlab does.  The N
dimensional array is the primary class.

The sort of freaky thing is that it can then be either a row or a
column vector depending on what the situation requires:

B=array([1,2,3])
shape(B)
A=array([[4,5,6],[7,8,9],[10,11,12]])
dot(A,B)#B is a column vector here
dot(B,A)#B is a row vector here

On 4/26/07, linda. s <samrobertsmith at gmail.com> wrote:
> I am curious about the (9,) for the shape. Does it mean 9 rows one
> column or one row 9 columns? The final array looks like one row 9
> columns but why (9,) gives me an impression that it is 9 rows one
> column? Thanks.
>
> >>> from numpy import *
> >>> numarr2
> array([[ 2,  4,  6],
>        [ 8, 10, 12],
>        [14, 16, 18]])
> >>> numarr2.shape = (9,)
> >>> print numarr2
> [ 2  4  6  8  0 12 14 16 18]
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list