-
Notifications
You must be signed in to change notification settings - Fork 114
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
Extrude and Resolve should be static on Manifold. #692
Extrude and Resolve should be static on Manifold. #692
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
@wrongbad would you like to take a look at this PR? Technically this is a breaking change, and it's a touch arbitrary. We leave this as a static method in the C++ to keep @briansturgill I believe the CLA is an automatic click through if you sign as an individual. It's pretty standard stuff, though slightly annoying. |
@elalish CLA has now been signed. |
Ah, good call, thanks for the explanation. Yes, just add another commit to your branch and push - the tests will automatically rerun. |
I have no idea what to do about the code formatting. It is very unclear from the "detail" what is being complained about. |
Have you tried our formatting script? https://github.com/elalish/manifold?tab=readme-ov-file#formatting |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #692 +/- ##
=======================================
Coverage 91.67% 91.67%
=======================================
Files 37 37
Lines 4730 4730
=======================================
Hits 4336 4336
Misses 394 394 ☔ View full report in Codecov by Sentry. |
From my POV... |
You pass in a function to use for the binding, which just happens to be a static method on Also I don't really see the point of simultaneously removing it from CrossSection since it is convenient to have there. We only don't have it that way in CPP because of the dependency. |
@geoffder |
Could you point me to documentation about this nanobind method making these assumptions (that it is a method, rather than a static one) about the provided function? As far as I understand, you can pass any function into For example, here we use a lambda: manifold/bindings/python/manifold3d.cpp Lines 268 to 273 in 887a502
In any case, if this usage really is in error, then the solution should rather be to write a wrapper function, than to remove the functionality entirely. |
Nanobind is a strongly typed c++ library. The only way to do what you're saying is to cast the function pointer through a Nanobind has a template/overload which picks up non-member functions (e.g. all the lambda wrappers are non-member functions) accepting the object as the first argument. There's nothing unsafe or undefined about the code. It's honestly pretty hard to read, but you can see the function wrapper overloads here: https://github.com/wjakob/nanobind/blob/master/include/nanobind/nb_func.h Edit: here's the part that matters:
basically whenever you pass an actual member function, nanobind internally wraps it in a lambda to become a function accepting the instance as the first argument, so it stores a consistent data structure for python to call later. When you pass a non-member function, this lambda step is skipped (using a different overload) because it's already the right function signature. When in doubt, read the code ;) |
I don't think it is an issue, and it is probably not very useful to make it a static function on manifold for the python binding considering it is much easier to use it as method chaining. |
Any consensus on this? I don't think this PR is needed. |
Perhaps just add the static method to the Python as well? Then it's not breaking, but also matches our C++ better. |
sounds good |
@pca006132 |
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.
Looks great, thanks!
else: | ||
return circle.revolve(int(m)).warp_batch(func) | ||
return Manifold.revolve(circle, int(m)).warp_batch(func) |
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.
Maybe leave one example using circle.extrude()
for variety? Unless there's already one that you didn't change.
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.
I think if we are having it in the all_apis.py
it should be fine.
* Extrude and Resolve should be static on Manifold. * Fixed unit test for extrude/revolve issue. * More test issues fixed. * Clean up formatting. * Placed extrude and revolve on both CrossSection and Manifold. * Formatting.
OK, the python binding has the Extrude and Revolve API calls as being member functions on CrossSection, when
in fact they are static on Manifold.
This PR fixes the problem.
#691