problem with numpy

tinu at email.ch tinu at email.ch
Mon Jan 8 02:27:21 EST 2001


Your problem is not a bug in Numeric, but a common mistake: 
You divide by an integer (integer array in your case), which gives you integer
division (the DIV operator in some Languages). 

Invoke all arrays explicitly as Float/Double, i.e.

    y = Numeric.zeros( x.shape, 'f' )        # output array
or  y = Numeric.zeros( x.shape, 'd' )        # output array
or  y = Numeric.zeros( x.shape, Numeric.Float ) # output array

and your result looks more realistic.

Don't-let-you-fool-by-implicit-type-definitons-ly

Martin



More information about the Python-list mailing list