Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstring generation tweaks #2212

Merged
merged 5 commits into from
Jun 10, 2020
Merged

Docstring generation tweaks #2212

merged 5 commits into from
Jun 10, 2020

Conversation

sizmailov
Copy link
Contributor

@sizmailov sizmailov commented May 14, 2020

This PR contains a couple of trivial tweaks which make generated docstring a bit better.

this PR master
a() -> numpy.ndarray[numpy.int32]
a() -> numpy.ndarray[int32]
b1(arg0: Iterator) -> None
b2(arg0: Iterable) -> None
b1(arg0: iterator) -> None
b2(arg0: iterable) -> None
c() -> numpy.ndarray
c() -> array
d() -> int
d() -> int_
compare.cpp
#include "pybind11/pybind11.h"
#include "pybind11/stl_bind.h"
#include "pybind11/embed.h"
#include "pybind11/numpy.h"

namespace py = pybind11;

PYBIND11_EMBEDDED_MODULE(example, m) {

  std::array<int, 3> data = {1, 2, 3};
  m.def("a", [&]{ return py::array_t({3, 1}, data.data()); });
  m.def("b1", [](py::iterator&) { });
  m.def("b2", [](py::iterable&) { });
  m.def("c", []{ return py::array(); });
  m.def("d", []{ return py::int_(0); });
}

int main() {
  py::scoped_interpreter guard{};
  py::exec(R"(
      from example import *
      print(a.__doc__, end="")
      print(b1.__doc__, end="")
      print(b2.__doc__, end="")
      print(c.__doc__, end="")
      print(d.__doc__, end="")
)");
}

@rwgk
Copy link
Collaborator

rwgk commented Jun 5, 2020

Hi Sergei, I'm helping out reviewing PRs, to take some load off Wenzel. Could you please split this PR into 3? E.g. commits 1-4 stay in this PR, 5, 6 each get their separate PR. That will allow me and Wenzel to act quicker on 1-4, and give us separate contexts to discuss the points you're raising. I'll look again asap after the split.

@sizmailov
Copy link
Contributor Author

Hi, Ralf! Thanks for looking into that. I've split PR in three as you suggested.

Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, just a minor question about tests for Iterable & Iterator.
I think inserting the numpy. is great for clarity.

include/pybind11/cast.h Show resolved Hide resolved
Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Sergei!

@sizmailov
Copy link
Contributor Author

fixed silenced flake8 spacing complaints

(travis.org seems to become quite unstable recently, probably migration to .com is required)

@wjakob wjakob merged commit ab323e0 into pybind:master Jun 10, 2020
@wjakob
Copy link
Member

wjakob commented Jun 10, 2020

These all look good to me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants