Unregister_scale() function to matplotlib.scale#31547
Open
dikshajangra12918-oss wants to merge 10 commits intomatplotlib:mainfrom
Open
Unregister_scale() function to matplotlib.scale#31547dikshajangra12918-oss wants to merge 10 commits intomatplotlib:mainfrom
dikshajangra12918-oss wants to merge 10 commits intomatplotlib:mainfrom
Conversation
Added unregister_scale(name) function that allows users to remove previously registered custom scales from the registry. Raises ValueError if the scale name is not found.
Added two test cases in test_scale.py: 1. test_unregister_scale: registers a temporary custom scale and verifies it is removed correctly. 2. test_unregister_scale_invalid: verifies that ValueError is raised when trying to unregister a scale that doesn't exist.
story645
reviewed
Apr 22, 2026
Co-authored-by: hannah <[email protected]>
Contributor
Author
|
The remaining failures are pre-existing issues with Qt backends and are unrelated to this PR. |
story645
reviewed
Apr 23, 2026
| assert 'temp_test_scale' not in mscale._scale_mapping | ||
|
|
||
|
|
||
| def test_unregister_scale_invalid(): |
Contributor
Author
There was a problem hiding this comment.
Thanks @story645!
I've updated the function and test names to use deregister_scale. Please taek a look.
Member
There was a problem hiding this comment.
still didn't catch everything,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Summary
Currently matplotlib has register_scale() but no way to remove a registered scale. This is a problem when a custom scale is created for just one plot — there is no way to clean up after that plot is drawn.
This PR adds unregister_scale(name) to fix that gap. Uses pop() for idiomatic dict cleanup.
Changes made:
~ Added unregister_scale() in lib/matplotlib/scale.py
~ Raises ValueError if scale name is not registered
~ Added tests in lib/matplotlib/tests/test_scale.py
Closes #5791
AI Disclosure
I used Claude (AI) for guidance on implementation approach. Code was written and verified by me.
PR Checklist
~ [x] Closes #5791 is in the PR description
~ [x] New code is tested