[Numpy-discussion] How to use decorator numpy.vectorize for methods in class

Robert Kern robert.kern@gmail....
Fri Jul 16 12:01:40 CDT 2010


On Fri, Jul 16, 2010 at 12:00, Shailendra <shailendra.vikas@gmail.com> wrote:
> Hi All,
> I tried to use the decorator @numpy.vectorize for the class method
> without success. Can any one point me to the correct way of using it?
> I am able to use the numpy.vectorize() sucessfully.
> Below is the code with did not work
>
> ==================== ================
> import numpy
> class test:
>    @numpy.vectorize  #<========= Using decorator
>    def add(self,x,y):
>        return x+y

numpy.vectorize does not work on methods, just functions.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list