From e5a045d9d74faf8667fa36bcf700877cb1386a9b Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sun, 11 Sep 2022 21:50:51 +0200 Subject: [PATCH] Expire parameter renaming and deletion and attribute privatization from 3.5 --- lib/matplotlib/axes/_base.py | 1 - lib/matplotlib/axis.py | 1 - lib/matplotlib/backends/backend_agg.py | 9 +++----- lib/matplotlib/backends/backend_ps.py | 6 ++--- lib/matplotlib/backends/backend_svg.py | 6 ++--- lib/matplotlib/backends/backend_template.py | 3 +-- .../backends/backend_webagg_core.py | 2 -- lib/matplotlib/colorbar.py | 14 ++--------- lib/matplotlib/dviread.py | 18 ++++----------- lib/matplotlib/figure.py | 17 +++++--------- lib/matplotlib/patches.py | 23 +++---------------- lib/matplotlib/texmanager.py | 5 ---- lib/mpl_toolkits/axes_grid1/axes_divider.py | 5 +--- lib/mpl_toolkits/axisartist/axislines.py | 1 - .../axisartist/grid_helper_curvelinear.py | 4 ---- lib/mpl_toolkits/mplot3d/axes3d.py | 1 - 16 files changed, 25 insertions(+), 91 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index ebe1ef7911d4..063ae489ef2d 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -3195,7 +3195,6 @@ def set_axisbelow(self, b): self.stale = True @_docstring.dedent_interpd - @_api.rename_parameter("3.5", "b", "visible") def grid(self, visible=None, which='major', axis='both', **kwargs): """ Configure the grid lines. diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 2f5dd6dcc0ea..5bfa002f9d96 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -1553,7 +1553,6 @@ def get_minor_ticks(self, numticks=None): return self.minorTicks[:numticks] - @_api.rename_parameter("3.5", "b", "visible") def grid(self, visible=None, which='major', **kwargs): """ Configure the grid lines. diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index 0d8a127dba8c..523181e5f475 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -449,8 +449,7 @@ def buffer_rgba(self): """ return self.renderer.buffer_rgba() - @_api.delete_parameter("3.5", "args") - def print_raw(self, filename_or_obj, *args): + def print_raw(self, filename_or_obj): FigureCanvasAgg.draw(self) renderer = self.get_renderer() with cbook.open_file_cm(filename_or_obj, "wb") as fh: @@ -468,8 +467,7 @@ def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None): filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper", dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs) - @_api.delete_parameter("3.5", "args") - def print_png(self, filename_or_obj, *args, + def print_png(self, filename_or_obj, metadata=None, pil_kwargs=None): """ Write the figure to a PNG file. @@ -529,8 +527,7 @@ def print_to_buffer(self): # print_figure(), and the latter ensures that `self.figure.dpi` already # matches the dpi kwarg (if any). - @_api.delete_parameter("3.5", "args") - def print_jpg(self, filename_or_obj, *args, pil_kwargs=None): + def print_jpg(self, filename_or_obj, pil_kwargs=None): # savefig() has already applied savefig.facecolor; we now set it to # white to make imsave() blend semi-transparent figures against an # assumed white background. diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index f209e811f18b..9676ba03428a 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -828,11 +828,9 @@ class FigureCanvasPS(FigureCanvasBase): def get_default_filetype(self): return 'ps' - @_api.delete_parameter("3.5", "args") def _print_ps( - self, fmt, outfile, *args, - metadata=None, papertype=None, orientation='portrait', - **kwargs): + self, fmt, outfile, metadata=None, papertype=None, + orientation='portrait', **kwargs): dpi = self.figure.dpi self.figure.dpi = 72 # Override the dpi kwarg diff --git a/lib/matplotlib/backends/backend_svg.py b/lib/matplotlib/backends/backend_svg.py index 7d94c429eed7..6d6398c96019 100644 --- a/lib/matplotlib/backends/backend_svg.py +++ b/lib/matplotlib/backends/backend_svg.py @@ -1314,8 +1314,7 @@ class FigureCanvasSVG(FigureCanvasBase): fixed_dpi = 72 - @_api.delete_parameter("3.5", "args") - def print_svg(self, filename, *args, bbox_inches_restore=None, + def print_svg(self, filename, bbox_inches_restore=None, metadata=None): """ Parameters @@ -1362,8 +1361,7 @@ def print_svg(self, filename, *args, bbox_inches_restore=None, self.figure.draw(renderer) renderer.finalize() - @_api.delete_parameter("3.5", "args") - def print_svgz(self, filename, *args, **kwargs): + def print_svgz(self, filename, **kwargs): with cbook.open_file_cm(filename, "wb") as fh, \ gzip.GzipFile(mode='w', fileobj=fh) as gzipwriter: return self.print_svg(gzipwriter, **kwargs) diff --git a/lib/matplotlib/backends/backend_template.py b/lib/matplotlib/backends/backend_template.py index 6b7aba9a504b..67aea9d811f0 100644 --- a/lib/matplotlib/backends/backend_template.py +++ b/lib/matplotlib/backends/backend_template.py @@ -197,8 +197,7 @@ def draw(self): # you should add it to the class-scope filetypes dictionary as follows: filetypes = {**FigureCanvasBase.filetypes, 'foo': 'My magic Foo format'} - @_api.delete_parameter("3.5", "args") - def print_foo(self, filename, *args, **kwargs): + def print_foo(self, filename, **kwargs): """ Write out format foo. diff --git a/lib/matplotlib/backends/backend_webagg_core.py b/lib/matplotlib/backends/backend_webagg_core.py index ee2d73d0cf95..e3115a372d43 100644 --- a/lib/matplotlib/backends/backend_webagg_core.py +++ b/lib/matplotlib/backends/backend_webagg_core.py @@ -389,8 +389,6 @@ class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2): if name_of_method in _ALLOWED_TOOL_ITEMS ] - cursor = _api.deprecate_privatize_attribute("3.5") - def __init__(self, canvas): self.message = '' self._cursor = None # Remove with deprecation. diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index b9293fbd902e..bf3f564793a4 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -353,11 +353,6 @@ def __init__(self, ax, mappable=None, *, cmap=None, for spine in self.ax.spines.values(): spine.set_visible(False) self.outline = self.ax.spines['outline'] = _ColorbarSpine(self.ax) - # Only kept for backcompat; remove after deprecation of .patch elapses. - self._patch = mpatches.Polygon( - np.empty((0, 2)), - color=mpl.rcParams['axes.facecolor'], linewidth=0.01, zorder=-1) - ax.add_artist(self._patch) self.dividers = collections.LineCollection( [], @@ -466,9 +461,6 @@ def _cbar_cla(self): del self.ax.cla self.ax.cla() - # Also remove ._patch after deprecation elapses. - patch = _api.deprecate_privatize_attribute("3.5", alternative="ax") - filled = _api.deprecate_privatize_attribute("3.6") def update_normal(self, mappable): @@ -849,8 +841,7 @@ def _get_ticker_locator_formatter(self): self._minorlocator = minorlocator _log.debug('locator: %r', locator) - @_api.delete_parameter("3.5", "update_ticks") - def set_ticks(self, ticks, update_ticks=True, labels=None, *, + def set_ticks(self, ticks, labels=None, *, minor=False, **kwargs): """ Set tick locations. @@ -890,8 +881,7 @@ def get_ticks(self, minor=False): else: return self._long_axis().get_majorticklocs() - @_api.delete_parameter("3.5", "update_ticks") - def set_ticklabels(self, ticklabels, update_ticks=True, *, minor=False, + def set_ticklabels(self, ticklabels, *, minor=False, **kwargs): """ [*Discouraged*] Set tick labels. diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index 8c83d8d6c508..531f6f1ea60d 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -1028,8 +1028,7 @@ def search(self, filename): @lru_cache() -@_api.delete_parameter("3.5", "format") -def _find_tex_file(filename, format=None): +def _find_tex_file(filename): """ Find a file in the texmf tree using kpathsea_. @@ -1057,15 +1056,13 @@ def _find_tex_file(filename, format=None): # out of caution if isinstance(filename, bytes): filename = filename.decode('utf-8', errors='replace') - if isinstance(format, bytes): - format = format.decode('utf-8', errors='replace') try: lk = _LuatexKpsewhich() except FileNotFoundError: lk = None # Fallback to directly calling kpsewhich, as below. - if lk and format is None: + if lk: path = lk.search(filename) else: @@ -1079,10 +1076,7 @@ def _find_tex_file(filename, format=None): kwargs = {'encoding': sys.getfilesystemencoding(), 'errors': 'surrogateescape'} - cmd = ['kpsewhich'] - if format is not None: - cmd += ['--format=' + format] - cmd += [filename] + cmd = ['kpsewhich', filename] try: path = (cbook._check_and_log_subprocess(cmd, _log, **kwargs) .rstrip('\n')) @@ -1099,11 +1093,9 @@ def _find_tex_file(filename, format=None): # After the deprecation period elapses, delete this shim and rename # _find_tex_file to find_tex_file everywhere. -@_api.delete_parameter("3.5", "format") -def find_tex_file(filename, format=None): +def find_tex_file(filename): try: - return (_find_tex_file(filename, format) if format is not None else - _find_tex_file(filename)) + return _find_tex_file(filename) except FileNotFoundError as exc: _api.warn_deprecated( "3.6", message=f"{exc.args[0]}; in the future, this will raise a " diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 5bbb786984d2..d8b2f0d6935c 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -121,26 +121,21 @@ def __init__(self, left=None, bottom=None, right=None, top=None, The height of the padding between subplots, as a fraction of the average Axes height. """ - self._validate = True for key in ["left", "bottom", "right", "top", "wspace", "hspace"]: setattr(self, key, mpl.rcParams[f"figure.subplot.{key}"]) self.update(left, bottom, right, top, wspace, hspace) - # Also remove _validate after deprecation elapses. - validate = _api.deprecate_privatize_attribute("3.5") - def update(self, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None): """ Update the dimensions of the passed parameters. *None* means unchanged. """ - if self._validate: - if ((left if left is not None else self.left) - >= (right if right is not None else self.right)): - raise ValueError('left cannot be >= right') - if ((bottom if bottom is not None else self.bottom) - >= (top if top is not None else self.top)): - raise ValueError('bottom cannot be >= top') + if ((left if left is not None else self.left) + >= (right if right is not None else self.right)): + raise ValueError('left cannot be >= right') + if ((bottom if bottom is not None else self.bottom) + >= (top if top is not None else self.top)): + raise ValueError('bottom cannot be >= top') if left is not None: self.left = left if right is not None: diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 76e65859ac73..e9b72c6c06b9 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -3853,11 +3853,8 @@ def __str__(self): @_docstring.dedent_interpd @_api.make_keyword_only("3.6", name="mutation_scale") - @_api.delete_parameter("3.4", "bbox_transmuter", alternative="boxstyle") - def __init__(self, xy, width, height, - boxstyle="round", bbox_transmuter=None, - mutation_scale=1, mutation_aspect=1, - **kwargs): + def __init__(self, xy, width, height, boxstyle="round", mutation_scale=1, + mutation_aspect=1, **kwargs): """ Parameters ---------- @@ -3905,17 +3902,7 @@ def __init__(self, xy, width, height, self._width = width self._height = height - if boxstyle == "custom": - _api.warn_deprecated( - "3.4", message="Support for boxstyle='custom' is deprecated " - "since %(since)s and will be removed %(removal)s; directly " - "pass a boxstyle instance as the boxstyle parameter instead.") - if bbox_transmuter is None: - raise ValueError("bbox_transmuter argument is needed with " - "custom boxstyle") - self._bbox_transmuter = bbox_transmuter - else: - self.set_boxstyle(boxstyle) + self.set_boxstyle(boxstyle) self._mutation_scale = mutation_scale self._mutation_aspect = mutation_aspect @@ -4436,10 +4423,6 @@ def _get_path_in_displaycoord(self): return _path, fillable - get_path_in_displaycoord = _api.deprecate_privatize_attribute( - "3.5", - alternative="self.get_transform().transform_path(self.get_path())") - def draw(self, renderer): if not self.get_visible(): return diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index c0d37edbc3d8..5e149ae29719 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -100,11 +100,6 @@ class TexManager: 'computer modern typewriter': 'monospace', } - grey_arrayd = _api.deprecate_privatize_attribute("3.5") - font_family = _api.deprecate_privatize_attribute("3.5") - font_families = _api.deprecate_privatize_attribute("3.5") - font_info = _api.deprecate_privatize_attribute("3.5") - @functools.lru_cache() # Always return the same instance. def __new__(cls): Path(cls.texcache).mkdir(parents=True, exist_ok=True) diff --git a/lib/mpl_toolkits/axes_grid1/axes_divider.py b/lib/mpl_toolkits/axes_grid1/axes_divider.py index 251fa44b14bf..2da039eee493 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_divider.py +++ b/lib/mpl_toolkits/axes_grid1/axes_divider.py @@ -492,8 +492,7 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs): ax.set_axes_locator(locator) return ax - @_api.delete_parameter("3.5", "add_to_figure", alternative="ax.remove()") - def append_axes(self, position, size, pad=None, add_to_figure=True, *, + def append_axes(self, position, size, pad=None, *, axes_class=None, **kwargs): """ Add a new axes on a given side of the main axes. @@ -524,8 +523,6 @@ def append_axes(self, position, size, pad=None, add_to_figure=True, *, }, position=position) ax = create_axes( size, pad, pack_start=pack_start, axes_class=axes_class, **kwargs) - if add_to_figure: - self._fig.add_axes(ax) return ax def get_aspect(self): diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index fdbf41580f03..a6852de2e99a 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -513,7 +513,6 @@ def clear(self): def get_grid_helper(self): return self._grid_helper - @_api.rename_parameter("3.5", "b", "visible") def grid(self, visible=None, which='major', axis="both", **kwargs): """ Toggle the gridlines, and optionally set the properties of the lines. diff --git a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py index 34117aac880b..c0ae25c45ea2 100644 --- a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py @@ -66,8 +66,6 @@ def get_tick_iterators(self, axes): class FloatingAxisArtistHelper(AxisArtistHelper.Floating): - grid_info = _api.deprecate_privatize_attribute("3.5") - def __init__(self, grid_helper, nth_coord, value, axis_direction=None): """ nth_coord = along which coordinate value varies. @@ -252,8 +250,6 @@ def get_line(self, axes): class GridHelperCurveLinear(GridHelperBase): - grid_info = _api.deprecate_privatize_attribute("3.5") - def __init__(self, aux_trans, extreme_finder=None, grid_locator1=None, diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 3177ed42ca25..31ea3c130f1f 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1187,7 +1187,6 @@ def set_frame_on(self, b): self._frameon = bool(b) self.stale = True - @_api.rename_parameter("3.5", "b", "visible") def grid(self, visible=True, **kwargs): """ Set / unset 3D grid.