[SciPy-user] convolve2d.. or Numeric to numarray conversion

Francesc Alted scipy-user@scipy.net
Fri, 14 Feb 2003 17:19:02 +0100


A Divendres 14 Febrer 2003 15:40, Kasper Souren va escriure:
> Is there another easy way to convert Numeric arrays to numarray arrays?
> (And the reverse would also be handy to have, but that's for later.)

I find this way specially fast as no actual data should be copied in the
process:

naarr =3D numarray.array(buffer(arr), type=3Darr.typecode(), shape=3Darr.=
shape)

that works for any Numeric object (except for typecode 'c').

And for the reverse case, this should work just fine:

arr=3DNumeric.array(naarr.tolist(), typecode=3Dnaarr.typecode())

although in this case, a data buffer copy is actually made.

Hope that helps,

--=20
Francesc Alted