[SciPy-user] newbie: easy question (I hope)

Gael Varoquaux gael.varoquaux@normalesup....
Mon Feb 5 10:54:16 CST 2007


On Mon, Feb 05, 2007 at 03:38:13PM +0000, Chiara Caronna wrote:
> I have an old code, where I used numarray, and there is this command:
> where c is a 1d array

> c= unpack(format, string)
> ccdimage=N.array(c,shape=[nrows,ncol])

> if I use array from numpy I got this error:

> "shape is an invalid keyword argument for this function"
> I need to transform c in an array of shape [nrows,ncol], how can I do it 
> with numpy?

c is an array, right, not, a list.

Then you can do something like

c = unpack(format, string)
ccdimage = N.reshape(c, (nrows, nol)) 

If c is a list you can convert it to a 1D array using N.array(c).

HTH,

Gaël


More information about the SciPy-user mailing list