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

Skip to content

Commit 2478913

Browse files
committed
Deprecate accepting arbitrary parameters in some get_window_extent() methods
1 parent d6ed6ce commit 2478913

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``Axes.get_window_extent`` and ``Figure.get_window_extent`` won't accept parameters other than *renderer* anymore
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
This aligns the API with the general `.Artist.get_window_extent` API.
4+
All parameters were ignored anyway.

lib/matplotlib/axes/_base.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,15 @@ def get_window_extent(self, *args, **kwargs):
734734
matplotlib.axis.Axis.get_tightbbox
735735
matplotlib.spines.Spine.get_window_extent
736736
"""
737+
if len(args) > 1 or kwargs.pop('renderer', None):
738+
# when this expires coerce the API to
739+
# get_window_extent(renderer=None) in line with
740+
# Artist.get_window_extent
741+
_api.warn_deprecated(
742+
"3.6",
743+
message="Passing any argument except 'renderer' to "
744+
"Axes.get_window_extent is deprecated in Matplotlib "
745+
"%(since)s and will be removed %(removal)s")
737746
return self.bbox
738747

739748
def _init_axis(self):

lib/matplotlib/figure.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,15 @@ def contains(self, mouseevent):
318318

319319
def get_window_extent(self, *args, **kwargs):
320320
# docstring inherited
321+
if len(args) > 1 or kwargs.pop('renderer', None):
322+
# when this expires coerce the API to
323+
# get_window_extent(renderer=None) in line with
324+
# Artist.get_window_extent
325+
_api.warn_deprecated(
326+
"3.6",
327+
message="Passing any argument except 'renderer' to "
328+
"Figure.get_window_extent is deprecated in Matplotlib "
329+
"%(since)s and will be removed %(removal)s")
321330
return self.bbox
322331

323332
def _suplabels(self, t, info, **kwargs):

0 commit comments

Comments
 (0)