refactor(pybind): use as_span for joint constitution bindings#405
refactor(pybind): use as_span for joint constitution bindings#405MuGdxy merged 2 commits intospiriMirror:mainfrom
Conversation
Replace manual py::list iteration with py::array_t and as_span/as_span_of for numeric parameters (IndexT, Float, Vector3) across all joint constitution pybind bindings, reducing boilerplate and improving type safety. Made-with: Cursor
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the Pybind11 bindings for various joint constitution mechanisms. The core objective is to modernize the handling of numeric array parameters passed from Python to C++ by leveraging Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors Pybind11 bindings across several joint-related files. It updates function signatures to accept py::array_t instead of py::list for various parameters, replacing manual iteration and casting with more efficient as_span utility calls. This change streamlines the C++ code and likely improves performance by leveraging NumPy arrays directly. The reviewer suggests consistently using curly braces for all loop bodies to enhance code clarity and prevent potential issues.
Address PR review feedback: use braces for all loop bodies for consistency and to prevent future modification bugs. Made-with: Cursor
Summary
py::listiteration withpy::array_t<T>andas_span<T>()/as_span_of<T>()for numeric parameters (IndexT,Float,Vector3) across all joint constitution pybind bindingspy::castloops, improving type safety and consistency with NumPy-native Python API