GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||
GeezerVison is showing github.com — Introduce `mpl::array` and `mpl::defer` by iccir · Pull Request #32532 · matplotlib/matplotlib Conversation
Contributor
PR summaryThis pull request adds a new ndarray Overviewnanobind provides an ndarray class for NumPy array access. While similar to pybind11's array class, it is not a drop-in replacement.
using TriangleArray = nb::ndarray<int, nb::shape<-1, 3>>; Unfortunately, nanobind is exceedingly vague when it fails to match a type signature to a bound function. When porting modules, you often end up with: The root cause can be your scalar is nanobind also requires that all typecasters be Typical RecommendationThe typical recommendation to the above problem is: "don't use a type caster, declare your function to take an static nb::tuple foo(nb::object src_object) { nb::ndarray<double, nb::device::cpu, nb::c_contig> foo_arr; if (nb::try_cast(src_object, rect_arr)) { … } … } This is not ideal:
My SolutionMy solution involves two parts: a simple wrapper which defers object creation combined with a modified array class which provides detailed error messages. mpl::defer
template <typename T> class defer : public py::object // (or nb::object) { … // PYBIND11_OBJECT_DEFAULT or NB_OBJECT_DEFAULT template <typename... Args> T value(Args &&...args) { return T(*this, args...); } }; This is used in a bound function as follows: static nb::tuple foo(const mpl::defer<DeferredObject> &src) { auto actual = src.value(); … } mpl::array
It will eventually replace several of our utility functions and classes:
In this PR, it wraps a Note For simplicity, an Qhull changesThe changes to qhull are straightforward:
C++ DisclosureThe creation of C++ container classes and heavy template metaprogramming is not something that I do everyday. It involves copious amounts of coffee, epic video game battle music, and intense focus. Please scrutinize accordingly. While most of the heavy lifting is directly ported from nanobind, I am still filling gaps in my C++ knowledge. AI Disclosure
PR quality check
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
iccir
force-pushed
the
pybind-mplarray-initial
branch
from
41da0ea to
c82b28b
Compare
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
iccir
marked this pull request as ready for review
…pybind-mplarray-initial
2 tasks done
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
This was referenced
This branch has not been deployedNo deployments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |