Skip to content

Commit

Permalink
MNT: Fix double evaluation of _LazyTickList
Browse files Browse the repository at this point in the history
Closes matplotlib#28908.

It seems the read-access to `instance.majorTicks` per `instance
.majorTicks.append()` still triggers the descriptor, even though
`instance.majorTicks = []` previously should have rebound the name. For
details see matplotlib#28908.
  • Loading branch information
timhoffm committed Sep 30, 2024
1 parent 6404c95 commit 8ea3d95
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import matplotlib.transforms as mtransforms
import matplotlib.units as munits

from line_profiler import profile
_log = logging.getLogger(__name__)

GRIDLINE_INTERPOLATION_STEPS = 180
Expand Down Expand Up @@ -531,6 +532,7 @@ class _LazyTickList:
def __init__(self, major):
self._major = major

@profile
def __get__(self, instance, owner):
if instance is None:
return self
Expand All @@ -543,12 +545,12 @@ def __get__(self, instance, owner):
if self._major:
instance.majorTicks = []
tick = instance._get_tick(major=True)
instance.majorTicks.append(tick)
instance.majorTicks = [tick]
return instance.majorTicks
else:
instance.minorTicks = []
tick = instance._get_tick(major=False)
instance.minorTicks.append(tick)
instance.minorTicks = [tick]
return instance.minorTicks


Expand Down

0 comments on commit 8ea3d95

Please sign in to comment.