Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b4887b

Browse files
committed
FIX: change to interval_contains_close
1 parent 61ea269 commit 2b4887b

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

lib/matplotlib/axis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,7 @@ def _update_ticks(self, renderer):
10511051
loct = None
10521052
continue
10531053
if ((loct is None) or
1054-
(not mtransforms.interval_contains(inter,
1055-
loct, rtol=1e-10))):
1054+
(not mtransforms.interval_contains_close(inter, loct))):
10561055
continue
10571056
ticks_to_draw.append(tick)
10581057

lib/matplotlib/transforms.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,10 +2892,33 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
28922892
return vmin, vmax
28932893

28942894

2895-
def interval_contains(interval, val, rtol=0):
2895+
def interval_contains(interval, val):
28962896
"""
28972897
Check, inclusively, whether an interval includes a given value.
28982898
2899+
Parameters
2900+
----------
2901+
interval : sequence of scalar
2902+
A 2-length sequence, endpoints that define the interval.
2903+
val : scalar
2904+
Value to check is within interval.
2905+
2906+
Returns
2907+
-------
2908+
bool
2909+
Returns true if given val is within the interval (with tolerance)
2910+
"""
2911+
a, b = interval
2912+
if a > b:
2913+
a, b = b, a
2914+
return a <= val <= b
2915+
2916+
2917+
def interval_contains_close(interval, val, rtol=1e-10):
2918+
"""
2919+
Check, inclusively, whether an interval includes a given value, with the
2920+
interval expanded by a small tolerance to admit floating point errors.
2921+
28992922
Parameters
29002923
----------
29012924
interval : sequence of scalar
@@ -2904,7 +2927,7 @@ def interval_contains(interval, val, rtol=0):
29042927
Value to check is within interval.
29052928
rtol : scalar
29062929
Tolerance slippage allowed outside of this interval. Default
2907-
0 * (b - a).
2930+
1e-10 * (b - a).
29082931
29092932
Returns
29102933
-------

0 commit comments

Comments
 (0)