Skip to content

Commit e736500

Browse files
committed
ticker: introduce atol/rtol for comparisons
1 parent 33376e9 commit e736500

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/ticker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,13 +2079,13 @@ def decade_up(x, base=10):
20792079
return base ** lx
20802080

20812081

2082-
def is_decade(x, base=10):
2082+
def is_decade(x, base=10, *, rtol=1e-10):
20832083
if not np.isfinite(x):
20842084
return False
20852085
if x == 0.0:
20862086
return True
20872087
lx = np.log(np.abs(x)) / np.log(base)
2088-
return is_close_to_int(lx)
2088+
return is_close_to_int(lx, atol=rtol)
20892089

20902090

20912091
def _decade_less_equal(x, base):
@@ -2138,8 +2138,8 @@ def _decade_greater(x, base):
21382138
return greater
21392139

21402140

2141-
def is_close_to_int(x):
2142-
return abs(x - np.round(x)) < 1e-10
2141+
def is_close_to_int(x, *, atol=1e-10):
2142+
return abs(x - np.round(x)) < atol
21432143

21442144

21452145
class LogLocator(Locator):

0 commit comments

Comments
 (0)