[Numpy-discussion] int and float ufunc?
Pearu Peterson
pearu at cens.ioc.ee
Mon Oct 7 14:42:09 CDT 2002
On Mon, 7 Oct 2002, Robert Kern wrote:
> 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)
> else:
> return __builtins__.int(object, **kwds)
>
> That should probably take care of all uses of int() in your code.
I would rename this function to `aint' and still change all the int(x) to
aint(x).
When messing with Python built-ins, sooner or later you'll find a bullet
in your leg ...
Pearu
More information about the Numpy-discussion
mailing list