pybind / pybind/python_example

Documentation generated with Sphinx

Aperta
#46 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
530
Fork
150
Merge medio
8g 2h
PR unite (30g)
1

Descrizione

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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Non sono indicati né un file sorgente né un test. Inizia confrontando i binding dei metodi pybind11 con le firme prodotte da Sphinx, usando il costruttore funzionante e i metodi non funzionanti come punti di ingresso a contrasto. Il lavoro è completato quando Sphinx conserva la firma completa di numpy.ndarray e il valore predefinito per questi metodi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, numpy, python
Ambito
documentation
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.