Skip to content

Fully adopt mpl::array and mpl::defer - #32536

Draft
iccir wants to merge 15 commits into
matplotlib:mainfrom
iccir:pybind-mplarray
Draft

iccir wants to merge 15 commits into
matplotlib:mainfrom
iccir:pybind-mplarray

Conversation

@iccir

@iccir iccir commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR summary

Important

This PR depends on #32532 and will appear larger than it really is until #32532 is merged. I will rebase this pull request against "main" prior to marking it as "Ready for review".

This PR converts the remainder of our py::array usage to mpl::array.

Naming Conventions

This PR attempts to make variable names and class member names consistent. We previously assigned "no suffix" to the pybind11 unchecked_reference proxy objects. In this PR, I assigned "no suffix" to mpl::array and use an _obj suffix for the raw incoming objects:

Type / Call Variable Name
mpl::defer<FooArray> or
std::optional<mpl::defer<…>>
foo_obj
FooArray foo
foo_arr.data() foo_data

Tri Changes

Previously, _tri.Triangulation used an empty tuple () to indicate a missing mask, edges, or neighbors parameter. This pull request changes the value used for "missing" to be None. This makes the nanobind transition easier as we can avoid std::variant.

Not Changed

The following still use py::array due to dtype specialization. They will eventually use nb::ndarray:

  • _path.is_sorted_and_has_non_nan()
  • _image.resample()

AI Disclosure

  • I use AI for web search due to search engines becoming less reliable.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [/] Plotting related features are demonstrated in an example
  • [/] New features and API changes have release notes
  • [/] Documentation complies with general and docstring guidelines

@iccir iccir mentioned this pull request Oct 30, 2026
@iccir iccir added this to nanobind Nov 2, 2026
@github-project-automation github-project-automation Bot moved this to Todo in nanobind Nov 2, 2026
@iccir iccir moved this from Todo to In Progress in nanobind Nov 2, 2026
…pybind-mplarray

# Conflicts:
#	lib/matplotlib/transforms.py
#	src/_path.h
#	src/_path_wrapper.cpp
@iccir
iccir marked this pull request as ready for review November 14, 2026 03:44
@iccir
iccir marked this pull request as draft November 14, 2026 03:44
@iccir iccir moved this from In Progress to Blocked in nanobind Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Blocked

Development

Successfully merging this pull request may close these issues.

1 participant