Description
Hi,
I'm currently trying to make some improvements to the healpy package (https://github.com/healpy/healpy), and pybind11 seems to be an almost perfect tool for the interfacing between Python and C++ that this package needs.
My first experiments went well, but then I hit the problem that the vectorize() functionality of pybind11 does not appear to support class member functions.
Assuming I have in C++
class foo {
public:
double bar(double arg);
};
I'd like to provide a Python function that takes either a scalar or a numpy array, calls foo::bar for all individual values, and then returns either a scalar or a numpy array. (The class object itself will always be a scalar.)
Is there a way to achieve this with current pybind11 versions? Naive application of vectorize() doesn't seem to work, like so:
py::class_<foo>(m, "foo")
.def("bar",py::vectorize(&foo::bar))
I'd be grateful for any tips!