Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@

_log = logging.getLogger(__name__)

# Fixed helper functions
def _is_close_to_int(x):

Check warning on line 149 in lib/matplotlib/ticker.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Expected 2 blank lines, found 1 Raw Output: message:"Expected 2 blank lines, found 1" location:{path:"?url=https%3A%2F%2Fgithub.com%2Fhome%2Frunner%2Fwork%2Fmatplotlib%2Fmatplotlib%2Flib%2Fmatplotlib%2Fticker.py" range:{start:{line:149 column:1} end:{line:149 column:4}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E302" url:"https://docs.astral.sh/ruff/rules/blank-lines-top-level"} suggestions:{range:{start:{line:147 column:1} end:{line:147 column:1}} text:"\n"}
"""Return True if x is close to an integer."""
return math.isclose(x, round(x), rel_tol=1e-9)

def _is_decade(x, *, base=10, rtol=None):

Check warning on line 153 in lib/matplotlib/ticker.py

View workflow job for this annotation

GitHub Actions / ruff

[rdjson] reported by reviewdog 🐶 Expected 2 blank lines, found 1 Raw Output: message:"Expected 2 blank lines, found 1" location:{path:"?url=https%3A%2F%2Fgithub.com%2Fhome%2Frunner%2Fwork%2Fmatplotlib%2Fmatplotlib%2Flib%2Fmatplotlib%2Fticker.py" range:{start:{line:153 column:1} end:{line:153 column:4}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E302" url:"https://docs.astral.sh/ruff/rules/blank-lines-top-level"} suggestions:{range:{start:{line:152 column:1} end:{line:153 column:1}} text:"\n\n"}
"""Return True if *x* is an integer power of *base*."""
if not np.isfinite(x):
return False
if x == 0.0:
return True
lx = np.log(abs(x)) / np.log(base)
if rtol is None:
return np.isclose(lx, np.round(lx))
else:
return np.isclose(lx, np.round(lx), rtol=rtol)

__all__ = ('TickHelper', 'Formatter', 'FixedFormatter',
'NullFormatter', 'FuncFormatter', 'FormatStrFormatter',
'StrMethodFormatter', 'ScalarFormatter', 'LogFormatter',
Expand Down
Loading