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

Travis Oliphant oliphant.travis at ieee.org
Tue Nov 28 01:10:49 CST 2006

konrad.hinsen at laposte.net wrote:
> 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?

Matplotlib uses the numerix layer to handle compatibility between all 
three array packages. 

It defines the typecode function in that package and then uses it 
instead of the method.


More information about the Numpy-discussion mailing list