Add helper functions for number checks and validations#31350
Closed
mohdabid4333-dotcom wants to merge 1 commit intomatplotlib:mainfrom
Closed
Add helper functions for number checks and validations#31350mohdabid4333-dotcom wants to merge 1 commit intomatplotlib:mainfrom
mohdabid4333-dotcom wants to merge 1 commit intomatplotlib:mainfrom
Conversation
Added helper functions to check if a number is close to an integer and if it is a power of a base.
Member
|
The two functions already exist in |
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.
Added helper functions to check if a number is close to an integer and if it is a power of a base.
PR Title
Add helper functions for number checks and validations in ticker.py
PR Summary
This PR introduces two internal helper functions to
lib/matplotlib/ticker.pyto streamline numeric validations and improve code readability for future ticker enhancements.Changes:
_is_close_to_int(x): A utility usingmath.iscloseto determine if a value is effectively an integer within a relative tolerance of_is_decade(x, *, base=10, rtol=None): A utility to determine if a given value is an integer power of a specified base (e.g.,Why is this change necessary?
These common checks are frequently needed when calculating tick positions and formatting labels, especially for logarithmic scales. Centralizing them as helper functions reduces code duplication and ensures consistent precision across the
tickermodule.AI Disclosure
I used an AI assistant to help format this PR description based on the code changes I authored.
PR Checklist