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

Skip to content

Simplify GridHelper invalidation. #19042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/deprecations/19042-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``GridHelperBase`` invalidation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``GridHelperBase.invalidate``, ``GridHelperBase.valid``, and
``axislines.Axes.invalidate_grid_helper`` methods are considered internal
and deprecated.
12 changes: 7 additions & 5 deletions lib/mpl_toolkits/axisartist/axislines.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,25 +315,26 @@ def _f(locs, labels):
class GridHelperBase:

def __init__(self):
self._force_update = True
self._force_update = True # Remove together with invalidate()/valid().
self._old_limits = None
super().__init__()

def update_lim(self, axes):
x1, x2 = axes.get_xlim()
y1, y2 = axes.get_ylim()

if self._force_update or self._old_limits != (x1, x2, y1, y2):
self._update(x1, x2, y1, y2)
self._update_grid(x1, y1, x2, y2)
self._force_update = False
self._old_limits = (x1, x2, y1, y2)

def _update(self, x1, x2, y1, y2):
pass
def _update_grid(self, x1, y1, x2, y2):
"""Cache relevant computations when the axes limits have changed."""

@_api.deprecated("3.4")
def invalidate(self):
self._force_update = True

@_api.deprecated("3.4")
def valid(self):
return not self._force_update

Expand Down Expand Up @@ -555,6 +556,7 @@ def get_children(self):
children.extend(super().get_children())
return children

@_api.deprecated("3.4")
def invalidate_grid_helper(self):
self._grid_helper.invalidate()

Expand Down
12 changes: 1 addition & 11 deletions lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ def __init__(self, aux_trans,
"""
super().__init__()
self.grid_info = None
self._old_values = None
self._aux_trans = aux_trans
self.grid_finder = GridFinder(aux_trans,
extreme_finder,
Expand All @@ -302,16 +301,7 @@ def update_grid_finder(self, aux_trans=None, **kw):
if aux_trans is not None:
self.grid_finder.update_transform(aux_trans)
self.grid_finder.update(**kw)
self.invalidate()

def _update(self, x1, x2, y1, y2):
"""bbox in 0-based image coordinates"""
# update wcsgrid
if self.valid() and self._old_values == (x1, x2, y1, y2):
return
self._update_grid(x1, y1, x2, y2)
self._old_values = (x1, x2, y1, y2)
self._force_update = False
self._old_limits = None # Force revalidation.

def new_fixed_axis(self, loc,
nth_coord=None,
Expand Down