-
Notifications
You must be signed in to change notification settings - Fork 119
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
python bindings: mirror and Mesh with 2 args #459
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. |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## master #459 +/- ##
=======================================
Coverage 89.94% 89.94%
=======================================
Files 35 35
Lines 4286 4286
=======================================
Hits 3855 3855
Misses 431 431 ☔ View full report in Codecov by Sentry. |
@pca006132 It looks like the existing |
Have you managed to sign the CLA yet? The formatting should be taken care of if you run clang-format. |
Yes I did sign.
I copy pasted the code from above, so the format is the same (unless I mixed tabs vs spaces)?
As said above, it comes from those "unchecked" calls. Maybe we can check for null and only do unchecked for those with the rest of the processing? I could check if it works on my side. Let me know if you have thoughts.
|
The canonical way for optional argument is manifold/bindings/python/pymanifold.cpp Line 591 in 6ae9dee
It should be simple to fix. |
Thanks to a post in pybind/pybind11#1953 (comment) I was able to properly make the argument optional. I also formatted using clang-format. 👌 |
I think we can just have empty array as the optional argument. That can simplify the code a bit. |
I couldn't find how to create empty arrays of specific dimensions. Any hint? py::arg("vert_normal") = py::array_t<float>(shape={0, 3}),
py::arg("halfedge_tangent") = py::array_t<float>(shape={0, 3})) this fails
|
py::arg("vert_normal") = std::vector<glm::vec3>(),
py::arg("halfedge_tangent") = std::vector<glm::vec4>()) |
@pca006132 Unfortunately it fails at
I wish I had a clue how to fix this. |
try |
@pca006132 Thanks. Still the same. I think it's expecting a real (allocated?) array because in python I was able to provide an empty as follows: m = pymanifold.Mesh(vertices.astype(np.float32),
faces.astype(np.int32),
# FIXME: Manifold forces Python binding to send arrays here
np.empty(shape=(0,0)), np.empty(shape=(0,0))
) See np.empty. No idea how to reproduce that in C++ |
No idea, a simple fix would be to provide a basic python script wrapper, similar to what we do with js. |
Any update? I'm proposing the following: (1) merging as is, (2) separating the change for mirror() into new PR so we can merge it and keep the Mesh() only here, so we can think about it (3) anyone can make that wrapper? I have no idea how to do it |
yeah I think we can just merge this |
* python bindings: Add mirror * python bindings: fix Mesh constructor optional arguments
* python bindings: Add mirror * python bindings: fix Mesh constructor optional arguments
Hello there,
I have noticed those two things are missing in the python bindings. I checked other methods and didn't see anything obvious more to add so far, it's a small PR.
.unchecked
it just refused the call). I'm sorry I did a copy paste, that looked like the easiest and simplest way to achieve it. Let me know if you have an idea how to make this better.I tested with my Python code. Hope this helps!