pybind/python_example

Documentation generated with Sphinx

tvatter opened this issue · 0 comments

Let's say that I have a C++ class myclass with a method double loglik(const Eigen::MatrixXd& u). To expose this method in python, I have something like .def("loglik", &myclass::loglik, "computes the log-likelihood.", py::arg("u")), which works fine. In other words, when doing help(mymodule.myclass), I see something like loglik(self: mymodule.myclass, u: numpy.ndarray[float64[m, n]]). However, when generating the documentation with Sphinx, the generated signature is loglik(self, u, n]]).

Similarly, I have a method in C++ with some argument const Eigen::MatrixXd& u = Eigen::MatrixXd() (i.e., the only difference is the "default"), which I expose in python using py::arg("u") = Eigen::MatrixXd(), and again this works fine, but the generated signature for the documentation is myfunction(self, u, n]] = array[, dtype])...

And it does not stop here. The same class has a constructor taking an argument const Eigen::MatrixXd& u, which I expose in python using .def(py::init<const Eigen::MatrixXd&>(), "my constructor", py::arg("u")). In this case, the signature generated by Sphinx is __init__(self: mymodule.myclass, u: numpy.ndarray[float64[m, n]]), so this one works as expected...

What am I missing here?