[Numpy-discussion] Wanted: Numeric/NumPy compatible array creation expression

konrad.hinsen at laposte.net konrad.hinsen at laposte.net
Thu Nov 23 09:24:08 EST 2006


I am looking for a way to create an array of the same type as another  
given array (but of different shape) that works both with Numeric and  
NumPy without being unreasonably slow. In other words, I am looking  
for a a replacement for the expression

	array2 = Numeric.zeros(shape, array1.typecode())

that will *also* (not *only*) work under NumPy (where typecode()  
became dtype.char). An obvious idea is reshaping array1 and  
multiplying by 0., but that can become quite costly.

Any ideas?

Konrad.
--
---------------------------------------------------------------------
Konrad Hinsen
Centre de Biophysique Moléculaire, CNRS Orléans
Synchrotron Soleil - Division Expériences
Saint Aubin - BP 48
91192 Gif sur Yvette Cedex, France
Tel. +33-1 69 35 97 15
E-Mail: hinsen at cnrs-orleans.fr
---------------------------------------------------------------------





More information about the NumPy-Discussion mailing list