[Numpy-discussion] int and float ufunc?

Robert Kern kern at caltech.edu
Mon Oct 7 13:02:05 CDT 2002

On Mon, Oct 07, 2002 at 11:56:48AM -0700, Andrew P. Lentvorski wrote:
> However, I have *lots* of these
> functions scattered around the code (inherited from someone else), so I
> will have to hunt them all down and change all the int(thingtoconvert) to
> thingtoconvert.astype('l').

How about defining a function like so:

def int(object, **kwds):
    if type(object) is Numeric.ArrayType:
        return object.astype(Numeric.Integer)
        return __builtins__.int(object, **kwds)

That should probably take care of all uses of int() in your code.

Robert Kern
Ruddock House President
kern at caltech.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

More information about the Numpy-discussion mailing list