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

Awkward pybind signatures #1666

Closed
Helveg opened this issue Sep 14, 2021 · 3 comments · Fixed by #1678
Closed

Awkward pybind signatures #1666

Helveg opened this issue Sep 14, 2021 · 3 comments · Fixed by #1678
Labels

Comments

@Helveg
Copy link
Collaborator

Helveg commented Sep 14, 2021

Describe the bug
arbor.mechanism's set of accepted arguments are a bit awkward because the signature with positional arguments has anonymous parameter names. It binds arg0 instead of name:

TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. arbor._arbor.mechanism(arg0: str)
    2. arbor._arbor.mechanism(name: str, params: Dict[str, float])

I suppose this occurs for all functions with similar signatures?

Shouldn't the signatures be:

1. arbor._arbor.mechanism(name: str)
2. arbor._arbor.mechanism(name: str, params: Dict[str, float])

I can do arbor.mechanism("name", {}) and arbor.mechanism(name="name", params={}) and arbor.mechanism("name") but not arbor.mechanism(name="name")

@Helveg Helveg added the bug label Sep 14, 2021
@brenthuisman
Copy link
Contributor

Afaik this is an effect of Pybind. The issue on this is still open: pybind/pybind11#2619

@Helveg
Copy link
Collaborator Author

Helveg commented Sep 22, 2021

That issue seems to be about the docstring generation. I can't find where it mentions which arg/kwarg overloads are actually accepted by pybind.

@brenthuisman
Copy link
Contributor

I understood that the docstring generation is a reflection of the way Pybind implements function overloads, it which case it always generates a func(*args, **kwargs) -> Any before the overloads and their signatures.

But I see now that you're asking why arg0 is named arg0, which is nowhere to be seen in https://github.com/arbor-sim/arbor/blob/master/python/mechanism.cpp#L204
Good question. Let me try something, I'll get back to this.

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

Successfully merging a pull request may close this issue.

2 participants