Re: [Numpy-discussion] force column vector

2007-02-09 Thread Alexander Schmolck
Christian <[EMAIL PROTECTED]> writes: > Hi, > > when creating an ndarray from a list, how can I force the result to be > 2d *and* a column vector? So in case I pass a nested list, there will be no > modification of the shape and when I pass a simple list, it will be > converted to a 2d column ve

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Charles R Harris
On 2/7/07, Christian <[EMAIL PROTECTED]> wrote: Sven Schreiber gmx.net> writes: > So I think what's needed is: > > b = array(yourlist) > b.reshape(b.shape[0], -1) Row vectors are easy to get. In [1]: asmatrix([1,2,3,4]) Out[1]: matrix([[1, 2, 3, 4]]) And nested lists work, but you will be

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Christian
Sven Schreiber gmx.net> writes: > So I think what's needed is: > > b = array(yourlist) > b.reshape(b.shape[0], -1) Yes! That is it. Thanks, Christian ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listi

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Christian
Christopher Barker noaa.gov> writes: > I'm not sure I understand the specification of the problem. I would > think that the definition of a column vector is that it's shape is: > > (-1,1) I was not aware of that possibility althoug I own the book I - shame on me. Thank you (and all others) for

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Robert Kern
Keith Goodman wrote: > I'd like to know what the -1 means. It means "fill in with whatever is necessary to make the size correct given the other specified dimensions". > But first I'm trying to figure out > why there are two reshapes? reshape() used to be simply a function, not a method. > Do t

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Keith Goodman
On 2/7/07, Sven Schreiber <[EMAIL PROTECTED]> wrote: > Christopher Barker schrieb: > > Christian wrote: > >> when creating an ndarray from a list, how can I force the result to be > >> 2d *and* a column vector? So in case I pass a nested list, there will be no > >> modification of the shape and whe

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Sven Schreiber
Christopher Barker schrieb: > Christian wrote: >> when creating an ndarray from a list, how can I force the result to be >> 2d *and* a column vector? So in case I pass a nested list, there will be no >> modification of the shape and when I pass a simple list, it will be >> converted to a 2d column

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Christopher Barker
Christian wrote: > when creating an ndarray from a list, how can I force the result to be > 2d *and* a column vector? So in case I pass a nested list, there will be no > modification of the shape and when I pass a simple list, it will be > converted to a 2d column vector. I'm not sure I understan

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Sven Schreiber
Christian schrieb: > Hi, > > when creating an ndarray from a list, how can I force the result to be > 2d *and* a column vector? So in case I pass a nested list, there will be no > modification of the shape and when I pass a simple list, it will be > converted to a 2d column vector. I can only thi

Re: [Numpy-discussion] force column vector

2007-02-07 Thread Stefan van der Walt
On Wed, Feb 07, 2007 at 10:35:14AM +, Christian wrote: > Hi, > > when creating an ndarray from a list, how can I force the result to be > 2d *and* a column vector? So in case I pass a nested list, there will be no > modification of the shape and when I pass a simple list, it will be > convert

[Numpy-discussion] force column vector

2007-02-07 Thread Christian
Hi, when creating an ndarray from a list, how can I force the result to be 2d *and* a column vector? So in case I pass a nested list, there will be no modification of the shape and when I pass a simple list, it will be converted to a 2d column vector. I can only think of a solution using 'if' cla