Skip to content

Move contour labeling methods into ContourSet - #32579

Open
sahilmathur254 wants to merge 3 commits into
matplotlib:mainfrom
sahilmathur254:fix/31793-inline-contour-labeler
Open

sahilmathur254 wants to merge 3 commits into
matplotlib:mainfrom
sahilmathur254:fix/31793-inline-contour-labeler

Conversation

@sahilmathur254

@sahilmathur254 sahilmathur254 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

PR summary

ContourLabeler provides labelling functionality solely for ContourSet, yet the separate mixin complicates documentation and relies on attributes defined by ContourSet. This PR consolidates the methods and type annotations within ContourSet and removes the mixin directly, following the maintainer’s guidance. Documentation and API removal notes are updated, with focused tests and before-and-after comparisons supporting preservation of existing labelling behaviour.

Direct removal follows the maintainer’s confirmation.

Closes #31793.

AI Disclosure

Codex assisted with the code changes, regression coverage, and validation in isolated Docker environments. The PR description was also drafted with AI assistance, and this PR was submitted by Codex with the contributor’s explicit authorisation.

Local validation

  • Contour and triangulation test modules: 161 passed, 4 skipped, both before and after the refactor. The skips were two PDF comparisons requiring Ghostscript and two SVG comparisons requiring Inkscape.
  • A local comparison across 24 labelling cases produced identical rendered pixels, label text, positions, rotations, and contour paths before and after the change. This covered direct, regular-grid, and triangular contours, automatic/manual placement, inline labels, and use_clabeltext.
  • Ruff and the repository-configured codespell check passed on the changed files.
  • Mypy passed for all 108 source files in an environment using the CI build and typing dependency groups. The focused contour runtime/stub comparison also passed.
  • A focused Sphinx build of the contour API page, Axes.clabel, and the removal note passed with warnings treated as errors. Links to unrelated guide pages were outside this focused check; the updated labeling links and method anchors were verified.
  • Four broken references in historical API notes were reproduced with a nitpicky Sphinx build and corrected to code literals; the same build then passed without warnings.

The full test suite and full documentation site were not run locally. GitHub CI results are available in the PR checks.

PR quality check

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

@sahilmathur254
sahilmathur254 marked this pull request as ready for review November 7, 2026 07:40

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

None yet

Development

Successfully merging this pull request may close these issues.

[MNT]: Inline ContourLabeler into ContourSet

3 participants