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

Travis Oliphant oliphant@ee.byu....
Mon Feb 5 13:20:59 CST 2007


Chiara Caronna wrote:

>Hi,
>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?
>  
>
What exactly are you asking?

If you want to use numarray-compatibile syntax then use the 
numpy.numarray module like this

import numpy.numarray as N

This is a compatibility-layer and is not recommended except for porting 
older code.

Otherwise you change the shape of an array using the reshape method or 
setting the shape attribute of an ndarray.

-Travis



More information about the SciPy-user mailing list