[SciPy-user] vector subtraction error

Evan Monroig evan.monroig at gmail.com
Sat Jan 7 19:32:08 EST 2006


On Jan.07 16h15, Ryan Krauss wrote :
> I understand what you are saying, but as far as I can tell, a vector
> with the shape of (n,) is neither a row nor a column.  It can't be
> transposed from one to the other:
> In [11]: shape(temp)
> Out[11]: (9,)
> 
> In [12]: temp2=transpose(temp)
> 
> In [13]: shape(temp2)
> Out[13]: (9,)

if temp is a (n,) array, you can add a new dimension to give it shape 
(n,1) or (1,n) :
>>> temp = rand(9)
>>> temp.shape
(9,)
>>> temp[NewAxis,:].shape
(1, 9)
>>> temp[:,NewAxis].shape
(9, 1)

Or you can reduce your (n,1) array to a 1-dimensional array:

>>> temp2.shape
(10, 1)
>>> squeeze(temp2).shape
(10,)

Evan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20060108/8a04390b/attachment.sig>


More information about the SciPy-User mailing list