On Mon, Oct 08, 2007 at 11:00:39PM +0100, Robin wrote:
> Hi,
>
> I am trying to implement a project in scipy. I think I am getting somewhere
> finally.
>
> However in my code (I am converting from MATLAB) it is important to maintain
> 2d
> arrays, and keep the difference between row and column vectors. After working
> through some initial problems I think I am getting more of a picture of how
> things work in numpy.
>
> However I am finding my code littered with things like:
> np.array(np.r_[0:nterms],ndmin=2) (for a row vector)
> or
> np.array(np.r_[0:nterms],ndmin=2).T (for a column vector)
You can use
N.arange(10).reshape(-1,1)
or
N.c_[:10,]
But if you use this sort of thing often, just write your own factory
method:
def col(n):
return N.arange(n).reshape(-1,1)
Cheers
Stéfan
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion