-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Add stubs for MeshTagsMetaClass #2219
Changes from all commits
e6ea2b5
03e797a
f86f463
802c5b0
3c4a7d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,7 @@ void declare_meshtags(py::module& m, std::string type) | |
})) | ||
.def_property_readonly("dtype", [](const dolfinx::mesh::MeshTags<T>& self) | ||
{ return py::dtype::of<T>(); }) | ||
.def_readwrite("name", &dolfinx::mesh::MeshTags<T>::name) | ||
.def_readwrite("_name", &dolfinx::mesh::MeshTags<T>::name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look good. We should seek a proper solution before merging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot have the same name for a property exposed to Python that has a getter and setter (causes infinite recursion). This would be the natural way to expose variables in a pythonic way. The main problem is that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One option instead of retyping the entire C++ module in python would be to automatically generate stubs (pyi files) for our pybind11 module: https://mypy.readthedocs.io/en/stable/stubgen.html or https://github.com/sizmailov/pybind11-stubgen However, I couldn't get it to work, admittedly only a five minute try. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main issue is that the directory of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually those tools produce draft stubs which often require some manual updates, I thought those would be committed. Creating them on-the-fly in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jorgensd Further to your comment #2219 (comment), do you not think that the 'fix' then would be to use the Pythonic constructors for MeshTags throughout? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that would be the correct way of fixing it. It would mean that we need to wrap up |
||
.def_property_readonly("dim", &dolfinx::mesh::MeshTags<T>::dim) | ||
.def_property_readonly("mesh", &dolfinx::mesh::MeshTags<T>::mesh) | ||
.def_property_readonly("values", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The underscore looks wrong in a demo - it's not idiomatic.