Improve MaxNLocator, AutoLocator signatures.#31788
Open
anntzer wants to merge 1 commit into
Open
Conversation
201ae87 to
cc2ccf3
Compare
Directly set the defaults of MaxNLocator in the constructor signature (with a cutout for `nbins=None`), rather than in a separate variable. Support passing kwargs to AutoLocator as well (they're already supported by MaxNLocator).
timhoffm
approved these changes
May 31, 2026
| min_n_ticks=2) | ||
|
|
||
| def __init__(self, nbins=None, **kwargs): | ||
| default_params = _api.deprecated("3.12")(property(lambda self: dict( |
Member
There was a problem hiding this comment.
Technically, this is breaking because it removes write access, i.e. replacing the whole dict, without prior warning.
But I think I'm ok with that. It should be very rare. https://github.com/search?q=%2FMaxNLocator%5C.default_params%2F+language%3APython+NOT+is%3Afork&type=code does not yield any such cases. If people overwrite defaults, they tend to do it on a per-element basis.
rcomer
reviewed
Jun 2, 2026
Comment on lines
+2130
to
+2135
| nbins=10, | ||
| steps=None, | ||
| integer=False, | ||
| symmetric=False, | ||
| prune=None, | ||
| min_n_ticks=2, |
Member
There was a problem hiding this comment.
Is it worth making these keyword-only, in case we want to re-order them or insert another parameter in future?
| kwargs['nbins'] = nbins | ||
| self.set_params(**{**self.default_params, **kwargs}) | ||
| self.set_params( | ||
| nbins=nbins if nbins is not None else 10, |
Member
There was a problem hiding this comment.
Do we need the check for None here? The parameter is documented as only taking an integer or "auto", and it already defaults to 10.
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.
Directly set the defaults of MaxNLocator in the constructor signature (with a cutout for
nbins=None), rather than in a separate variable.Support passing kwargs to AutoLocator as well (they're already supported by MaxNLocator).
PR summary
AI Disclosure
PR checklist