Skip to content

Commit

Permalink
Merge pull request SciTools#2424 from rcomer/tight_bbox
Browse files Browse the repository at this point in the history
Make renderer parameter optional in GeoAxes.get_tightbbox
  • Loading branch information
dopplershift authored Aug 20, 2024
2 parents 02c6bc3 + 454567a commit c86f49f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def hold_limits(self, hold=True):
self.get_autoscaley_on())
yield

def _draw_preprocess(self, renderer):
def _draw_preprocess(self):
"""
Perform pre-processing steps shared between :func:`GeoAxes.draw`
and :func:`GeoAxes.get_tightbbox`.
Expand All @@ -484,7 +484,7 @@ def _draw_preprocess(self, renderer):
# by `draw` or `get_tightbbox` are positioned and clipped correctly.
self.patch._adjust_location()

def get_tightbbox(self, renderer, *args, **kwargs):
def get_tightbbox(self, renderer=None, *args, **kwargs):
"""
Extend the standard behaviour of
:func:`matplotlib.axes.Axes.get_tightbbox`.
Expand All @@ -493,7 +493,7 @@ def get_tightbbox(self, renderer, *args, **kwargs):
calculating the tight bounding box.
"""
# Shared processing steps
self._draw_preprocess(renderer)
self._draw_preprocess()

return super().get_tightbbox(renderer, *args, **kwargs)

Expand All @@ -506,7 +506,7 @@ def draw(self, renderer=None, **kwargs):
A global range is used if no limits have yet been set.
"""
# Shared processing steps
self._draw_preprocess(renderer)
self._draw_preprocess()

# XXX This interface needs a tidy up:
# image drawing on pan/zoom;
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/tests/mpl/test_gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def test_gridliner_count_draws():
gl = ax.gridlines()

with mock.patch.object(gl, '_draw_gridliner', return_value=None) as mocked:
ax.get_tightbbox(renderer=None)
ax.get_tightbbox()
mocked.assert_called_once()

with mock.patch.object(gl, '_draw_gridliner', return_value=None) as mocked:
Expand Down

0 comments on commit c86f49f

Please sign in to comment.