Is it possible to numpy.vectorize an instance method?

前端 未结 5 508
我在风中等你
我在风中等你 2021-01-17 08:51

I\'ve found that the numpy.vectorize allows one to convert \'ordinary\' functions which expect a single number as input to a function which can also convert a list of inputs

5条回答
  •  死守一世寂寞
    2021-01-17 09:27

    From the docs:

    The data type of the output of vectorized is determined by calling the function with the first element of the input. This can be avoided by specifying the otypes argument.

    The first input in your function f(self, x) is self. Maybe you can make that function a wrapper around a staticmethod function?

提交回复
热议问题