Skip to content

Expire parameter renaming and deletion and attribute privatization from 3.5 #23874

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Copy link
Contributor

@anntzer anntzer Sep 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you expire a delete_parameter, all subsequent parameters also become kwonly (as it was impossible to pass them positionally during the deprecation period without triggering the deprecation). Ditto for all other instances below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that. Makes sense!

metadata=None, pil_kwargs=None):
"""
Write the figure to a PNG file.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/backends/backend_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 2 additions & 12 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[],
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 5 additions & 13 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_.

Expand Down Expand Up @@ -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:
Expand All @@ -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'))
Expand All @@ -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 "
Expand Down
17 changes: 6 additions & 11 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 3 additions & 20 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions lib/mpl_toolkits/axes_grid1/axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion lib/mpl_toolkits/axisartist/axislines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down