From 283d322f8f6aff6acd83311512a51ef8e45f79af Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 18:11:50 -0400 Subject: [PATCH 01/10] Remove keyword arguments deprecated in 3.0. These were documented as being removed in 3.1, though should have been at least 3.2, but 3.3 works. --- doc/api/api_changes_3.3/removals.rst | 4 +++ lib/matplotlib/patches.py | 26 ------------------- lib/mpl_toolkits/axisartist/axisline_style.py | 1 - 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/doc/api/api_changes_3.3/removals.rst b/doc/api/api_changes_3.3/removals.rst index 8d50ae6e54b8..929189d4c617 100644 --- a/doc/api/api_changes_3.3/removals.rst +++ b/doc/api/api_changes_3.3/removals.rst @@ -195,6 +195,10 @@ Arguments other than ``ticklabels``. - ``mpl_toolkits.mplot3d.art3d.Poly3DCollection.set_zsort`` does not accept the value ``True`` anymore. Pass the equivalent value 'average' instead. +- `~.ConnectionPatch` no longer accepts the ``arrow_transmuter`` and + ``connector`` keyword arguments, which did nothing since 3.0. +- `~.FancyArrowPatch` no longer accepts the ``arrow_transmuter`` and + ``connector`` keyword arguments, which did nothing since 3.0. rcParams ~~~~~~~~ diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 539d970f5443..a1e06c26172b 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -3825,9 +3825,7 @@ def __str__(self): def __init__(self, posA=None, posB=None, path=None, arrowstyle="simple", - arrow_transmuter=None, connectionstyle="arc3", - connector=None, patchA=None, patchB=None, shrinkA=2, @@ -3866,9 +3864,6 @@ def __init__(self, posA=None, posB=None, %(AvailableArrowstyles)s - arrow_transmuter - Ignored. - connectionstyle : str or `.ConnectionStyle` or None, optional, \ default: 'arc3' The `.ConnectionStyle` with which *posA* and *posB* are connected. @@ -3878,9 +3873,6 @@ def __init__(self, posA=None, posB=None, %(AvailableConnectorstyles)s - connector - Ignored. - patchA, patchB : `.Patch`, default: None Head and tail patches, respectively. @@ -3910,20 +3902,6 @@ def __init__(self, posA=None, posB=None, In contrast to other patches, the default ``capstyle`` and ``joinstyle`` for `FancyArrowPatch` are set to ``"round"``. """ - if arrow_transmuter is not None: - cbook.warn_deprecated( - 3.0, - message=('The "arrow_transmuter" keyword argument is not used,' - ' and will be removed in Matplotlib 3.1'), - name='arrow_transmuter', - obj_type='keyword argument') - if connector is not None: - cbook.warn_deprecated( - 3.0, - message=('The "connector" keyword argument is not used,' - ' and will be removed in Matplotlib 3.1'), - name='connector', - obj_type='keyword argument') # Traditionally, the cap- and joinstyle for FancyArrowPatch are round kwargs.setdefault("joinstyle", "round") kwargs.setdefault("capstyle", "round") @@ -4193,9 +4171,7 @@ def __str__(self): def __init__(self, xyA, xyB, coordsA, coordsB=None, axesA=None, axesB=None, arrowstyle="-", - arrow_transmuter=None, connectionstyle="arc3", - connector=None, patchA=None, patchB=None, shrinkA=0., @@ -4278,9 +4254,7 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None, FancyArrowPatch.__init__(self, posA=(0, 0), posB=(1, 1), arrowstyle=arrowstyle, - arrow_transmuter=arrow_transmuter, connectionstyle=connectionstyle, - connector=connector, patchA=patchA, patchB=patchB, shrinkA=shrinkA, diff --git a/lib/mpl_toolkits/axisartist/axisline_style.py b/lib/mpl_toolkits/axisartist/axisline_style.py index 12946516b6ea..79fbe496c4bd 100644 --- a/lib/mpl_toolkits/axisartist/axisline_style.py +++ b/lib/mpl_toolkits/axisartist/axisline_style.py @@ -21,7 +21,6 @@ def __init__(self, axis_artist, line_path, transform, FancyArrowPatch.__init__(self, path=self._line_path, arrowstyle=self._ARROW_STYLE, - arrow_transmuter=None, patchA=None, patchB=None, shrinkA=0., From ec8dbab39711147ca44f89647170ec7ef29f232c Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 18:33:15 -0400 Subject: [PATCH 02/10] Remove deprecated arguments and keyword arguments. --- doc/api/api_changes_3.3/removals.rst | 11 ++++++++--- lib/matplotlib/backends/backend_nbagg.py | 8 +------- lib/matplotlib/offsetbox.py | 8 +++----- lib/matplotlib/textpath.py | 8 +------- lib/matplotlib/ticker.py | 5 ++--- 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/doc/api/api_changes_3.3/removals.rst b/doc/api/api_changes_3.3/removals.rst index 929189d4c617..04d3d8f3953a 100644 --- a/doc/api/api_changes_3.3/removals.rst +++ b/doc/api/api_changes_3.3/removals.rst @@ -176,7 +176,8 @@ Arguments - The unused parameter ``interp_at_native`` of `.BboxImage` has been removed. - The parameter ``usetex`` of `.TextToPath.get_text_path` has been removed. Use ``ismath='TeX'`` instead. -- The parameter ``block`` of ``show()`` is now keyword-only. +- The parameter ``block`` of ``show()`` is now keyword-only, and arbitrary + arguments or keyword arguments are no longer accepted. - The parameter ``frameon`` of `.Figure.savefig` has been removed. Use ``facecolor="none"`` to get a transparent background. - Passing a ``wx.EvtHandler`` as the first argument to ``backend_wx.TimerWx`` @@ -195,10 +196,14 @@ Arguments other than ``ticklabels``. - ``mpl_toolkits.mplot3d.art3d.Poly3DCollection.set_zsort`` does not accept the value ``True`` anymore. Pass the equivalent value 'average' instead. -- `~.ConnectionPatch` no longer accepts the ``arrow_transmuter`` and +- `.AnchoredText` no longer accepts ``horizontalalignment`` or + ``verticalalignment`` keyword arguments. +- `.ConnectionPatch` no longer accepts the ``arrow_transmuter`` and ``connector`` keyword arguments, which did nothing since 3.0. -- `~.FancyArrowPatch` no longer accepts the ``arrow_transmuter`` and +- `.FancyArrowPatch` no longer accepts the ``arrow_transmuter`` and ``connector`` keyword arguments, which did nothing since 3.0. +- `.TextPath` no longer accepts arbitrary positional or keyword arguments. +- `.MaxNLocator.set_params()` no longer accepts arbitrary keyword arguments. rcParams ~~~~~~~~ diff --git a/lib/matplotlib/backends/backend_nbagg.py b/lib/matplotlib/backends/backend_nbagg.py index 49e3d514ad03..200ef2c88732 100644 --- a/lib/matplotlib/backends/backend_nbagg.py +++ b/lib/matplotlib/backends/backend_nbagg.py @@ -239,13 +239,7 @@ def trigger_manager_draw(manager): manager.show() @staticmethod - def show(*args, block=None, **kwargs): - if args or kwargs: - cbook.warn_deprecated( - "3.1", message="Passing arguments to show(), other than " - "passing 'block' by keyword, is deprecated %(since)s, and " - "support for it will be removed %(removal)s.") - + def show(block=None): ## TODO: something to do when keyword block==False ? from matplotlib._pylab_helpers import Gcf diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index 1d1a24849532..c4c743472163 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -1285,11 +1285,9 @@ def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs): prop = {} badkwargs = {'ha', 'horizontalalignment', 'va', 'verticalalignment'} if badkwargs & set(prop): - cbook.warn_deprecated( - "3.1", message="Mixing horizontalalignment or " - "verticalalignment with AnchoredText is not supported, " - "deprecated since %(since)s, and will raise an exception " - "%(removal)s.") + raise ValueError( + "Mixing horizontalalignment or verticalalignment with " + "AnchoredText is not supported.") self.txt = TextArea(s, textprops=prop, minimumdescent=False) fp = self.txt._text.get_fontproperties() diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py index 63284ea6d61d..4daedaeb22eb 100644 --- a/lib/matplotlib/textpath.py +++ b/lib/matplotlib/textpath.py @@ -349,8 +349,7 @@ class TextPath(Path): """ def __init__(self, xy, s, size=None, prop=None, - _interpolation_steps=1, usetex=False, - *args, **kwargs): + _interpolation_steps=1, usetex=False): r""" Create a path from the text. Note that it simply is a path, not an artist. You need to use the `~.PathPatch` (or other artists) @@ -396,11 +395,6 @@ def __init__(self, xy, s, size=None, prop=None, # Circular import. from matplotlib.text import Text - if args or kwargs: - cbook.warn_deprecated( - "3.1", message="Additional arguments to TextPath used to be " - "ignored, but will trigger a TypeError %(removal)s.") - if prop is None: prop = FontProperties() else: diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 0ed9d489c06a..277f55a1afab 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2095,9 +2095,8 @@ def set_params(self, **kwargs): self._integer = kwargs.pop('integer') if kwargs: key, _ = kwargs.popitem() - cbook.warn_deprecated("3.1", - message="MaxNLocator.set_params got an " - f"unexpected parameter: {key}") + raise TypeError( + f"set_params() got an unexpected keyword argument '{key}'") def _raw_ticks(self, vmin, vmax): """ From 73815614ecccb64797b5e23336de71a106aa73f3 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 19:06:06 -0400 Subject: [PATCH 03/10] Fix sorting of 3.3's API removals. --- doc/api/api_changes_3.3/removals.rst | 82 +++++++++++++++------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/doc/api/api_changes_3.3/removals.rst b/doc/api/api_changes_3.3/removals.rst index 04d3d8f3953a..352f14f6e280 100644 --- a/doc/api/api_changes_3.3/removals.rst +++ b/doc/api/api_changes_3.3/removals.rst @@ -9,6 +9,10 @@ Modules Classes, methods and attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- ``artist.Artist.aname`` property (no replacement) + +- ``axis.Axis.iter_ticks`` (no replacement) + - ``backend_bases.RendererBase.strip_math()`` (use ``cbook.strip_math()`` instead) @@ -39,6 +43,8 @@ Classes, methods and attributes - ``backend_qt5.NavigationToolbar2QT.buttons`` property (no replacement) - ``backend_qt5.NavigationToolbar2QT.adj_window`` property (no replacement) +- ``bezier.find_r_to_boundary_of_closedpath()`` (no replacement) + - ``cbook.dedent()`` (use `inspect.cleandoc` instead) - ``cbook.get_label()`` (no replacement) - ``cbook.is_hashable()`` (use ``isinstance(..., collections.abc.Hashable)`` @@ -46,11 +52,30 @@ Classes, methods and attributes - ``cbook.iterable()`` (use ``numpy.iterable()`` instead) - ``cbook.safezip()`` (no replacement) +- ``colorbar.ColorbarBase.get_cmap`` (use ``ScalarMappable.get_cmap`` instead) +- ``colorbar.ColorbarBase.set_cmap`` (use ``ScalarMappable.set_cmap`` instead) +- ``colorbar.ColorbarBase.get_clim`` (use ``ScalarMappable.get_clim`` instead) +- ``colorbar.ColorbarBase.set_clim`` (use ``ScalarMappable.set_clim`` instead) +- ``colorbar.ColorbarBase.set_norm`` (use ``ScalarMappable.set_norm`` instead) + +- ``dates.seconds()`` (no replacement) +- ``dates.minutes()`` (no replacement) +- ``dates.hours()`` (no replacement) +- ``dates.weeks()`` (no replacement) +- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or + `dateutil.parser.parse` or `.dates.datestr2num` instead) + - ``docstring.Appender`` (no replacement) - ``docstring.dedent()`` (use `inspect.getdoc` instead) - ``docstring.copy_dedent()`` (use ``docstring.copy()`` and `inspect.getdoc` instead) +- ``font_manager.OSXInstalledFonts()`` (no replacement) + +- ``image.BboxImage.interp_at_native`` property (no replacement) + +- ``lines.Line2D.verticalOffset`` property (no replacement) + - ``matplotlib.checkdep_dvipng`` (no replacement) - ``matplotlib.checkdep_ghostscript`` (no replacement) - ``matplotlib.checkdep_pdftops`` (no replacement) @@ -58,19 +83,26 @@ Classes, methods and attributes - ``matplotlib.get_py2exe_datafiles`` (no replacement) - ``matplotlib.tk_window_focus`` (use ``rcParams['tk.window_focus']`` instead) +- ``mlab.demean()`` (use ``mlab.detrend_mean()`` instead) + +- ``path.get_paths_extents()`` + (use ``path.get_path_collection_extents()`` instead) + +- ``projections.process_projection_requirements()`` (no replacement) + - ``pyplot.plotfile()`` (Instead, load the data using `pandas.read_csv` or `numpy.loadtxt` or similar and use regular pyplot functions to plot the loaded data.) + +- ``quiver.Quiver.color()`` (use ``Quiver.get_facecolor()`` instead) +- ``quiver.Quiver.keyvec`` property (no replacement) +- ``quiver.Quiver.keytext`` property (no replacement) + - ``rcsetup.validate_qt4()`` (no replacement) - ``rcsetup.validate_qt5()`` (no replacement) - ``rcsetup.validate_verbose()`` (no replacement) - ``rcsetup.ValidateInterval`` (no replacement) -- ``sphinxext.plot_directive.plot_directive()`` - (use the class ``PlotDirective`` instead) -- ``sphinxext.mathmpl.math_directive()`` - (use the class ``MathDirective`` instead) - - ``scale.LogTransformBase`` (use ``scale.LogTransform`` instead) - ``scale.InvertedLogTransformBase`` (use ``scale.InvertedLogTransform`` instead) - ``scale.Log10Transform`` (use ``scale.LogTransform`` instead) @@ -80,6 +112,11 @@ Classes, methods and attributes - ``scale.NaturalLogTransform`` (use ``scale.LogTransform`` instead) - ``scale.InvertedNaturalLogTransform`` (use ``scale.InvertedLogTransform`` instead) +- ``sphinxext.plot_directive.plot_directive()`` + (use the class ``PlotDirective`` instead) +- ``sphinxext.mathmpl.math_directive()`` + (use the class ``MathDirective`` instead) + - ``spines.Spine.is_frame_like()`` (no replacement) - ``text.Text.is_math_text()`` (use ``cbook.is_math_text()`` instead) @@ -98,38 +135,7 @@ Classes, methods and attributes ``Tick.tick1line``, ``Tick.tick2line``, ``Tick.label1``, ``Tick.label2`` instead) -- ``Artist.aname`` property (no replacement) -- ``Axis.iter_ticks`` (no replacement) - -- ``image.BboxImage.interp_at_native`` property (no replacement) -- ``lines.Line2D.verticalOffset`` property (no replacement) -- ``bezier.find_r_to_boundary_of_closedpath()`` (no replacement) - -- ``quiver.Quiver.color()`` (use ``Quiver.get_facecolor()`` instead) -- ``quiver.Quiver.keyvec`` property (no replacement) -- ``quiver.Quiver.keytext`` property (no replacement) - -- ``colorbar.ColorbarBase.get_cmap`` (use ``ScalarMappable.get_cmap`` instead) -- ``colorbar.ColorbarBase.set_cmap`` (use ``ScalarMappable.set_cmap`` instead) -- ``colorbar.ColorbarBase.get_clim`` (use ``ScalarMappable.get_clim`` instead) -- ``colorbar.ColorbarBase.set_clim`` (use ``ScalarMappable.set_clim`` instead) -- ``colorbar.ColorbarBase.set_norm`` (use ``ScalarMappable.set_norm`` instead) - -- ``dates.seconds()`` (no replacement) -- ``dates.minutes()`` (no replacement) -- ``dates.hours()`` (no replacement) -- ``dates.weeks()`` (no replacement) -- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or - `dateutil.parser.parse` or `.dates.datestr2num` instead) - -- ``font_manager.OSXInstalledFonts()`` (no replacement) - -- ``mlab.demean()`` (use ``mlab.detrend_mean()`` instead) - -- ``projections.process_projection_requirements()`` (no replacement) - -- ``path.get_paths_extents()`` - (use ``path.get_path_collection_extents()`` instead) +- ``widgets.SpanSelector.buttonDown`` property (no replacement) - ``mplot3d.proj3d.line2d()`` (no replacement) - ``mplot3d.proj3d.line2d_dist()`` (no replacement) @@ -159,8 +165,6 @@ Classes, methods and attributes - ``axisartist.axislines.Axes.AxisDict`` (use ``axis_grid1.mpl_axes.Axes.AxisDict`` instead) -- ``widgets.SpanSelector.buttonDown`` property (no replacement) - Arguments ~~~~~~~~~ - ``Axes.text()`` / ``pyplot.text()`` do not support the parameter ``withdash`` From 2088794fae628483aff1917a07c92733a2ca420f Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 19:24:02 -0400 Subject: [PATCH 04/10] Remove functions/methods deprecated in 3.1. --- doc/api/api_changes_3.3/removals.rst | 9 +++++++++ .../prev_api_changes/api_changes_3.1.0.rst | 9 +++++---- doc/missing-references.json | 5 +---- lib/matplotlib/path.py | 9 --------- lib/matplotlib/pyplot.py | 2 +- lib/matplotlib/scale.py | 10 ---------- lib/matplotlib/testing/decorators.py | 20 ------------------- lib/matplotlib/textpath.py | 10 ---------- 8 files changed, 16 insertions(+), 58 deletions(-) diff --git a/doc/api/api_changes_3.3/removals.rst b/doc/api/api_changes_3.3/removals.rst index 352f14f6e280..693cae71a229 100644 --- a/doc/api/api_changes_3.3/removals.rst +++ b/doc/api/api_changes_3.3/removals.rst @@ -87,6 +87,8 @@ Classes, methods and attributes - ``path.get_paths_extents()`` (use ``path.get_path_collection_extents()`` instead) +- ``path.Path.has_nonfinite()`` (use ``not np.isfinite(self.vertices).all()`` + instead) - ``projections.process_projection_requirements()`` (no replacement) @@ -111,6 +113,7 @@ Classes, methods and attributes - ``scale.InvertedLog2Transform`` (use ``scale.InvertedLogTransform`` instead) - ``scale.NaturalLogTransform`` (use ``scale.LogTransform`` instead) - ``scale.InvertedNaturalLogTransform`` (use ``scale.InvertedLogTransform`` instead) +- ``scale.get_scale_docs()`` (no replacement) - ``sphinxext.plot_directive.plot_directive()`` (use the class ``PlotDirective`` instead) @@ -119,12 +122,18 @@ Classes, methods and attributes - ``spines.Spine.is_frame_like()`` (no replacement) +- ``testing.decorators.switch_backend()`` (use ``@pytest.mark.backend`` + decorator instead) + - ``text.Text.is_math_text()`` (use ``cbook.is_math_text()`` instead) - ``text.TextWithDash()`` (use ``text.Annotation`` instead) - ``textpath.TextPath.is_math_text()`` (use ``cbook.is_math_text()`` instead) - ``textpath.TextPath.text_get_vertices_codes()`` (use ``textpath.text_to_path.get_text_path()`` instead) +- ``textpath.TextToPath.glyph_to_path()`` (use ``font.get_path()`` and manual + translation of the vertices instead) + - ``ticker.OldScalarFormatter.pprint_val()`` (no replacement) - ``ticker.ScalarFormatter.pprint_val()`` (no replacement) - ``ticker.LogFormatter.pprint_val()`` (no replacement) diff --git a/doc/api/prev_api_changes/api_changes_3.1.0.rst b/doc/api/prev_api_changes/api_changes_3.1.0.rst index 769b43bdcecd..90d4fc3548bd 100644 --- a/doc/api/prev_api_changes/api_changes_3.1.0.rst +++ b/doc/api/prev_api_changes/api_changes_3.1.0.rst @@ -849,8 +849,8 @@ Use the standard library's docstring manipulation tools instead, such as -- `matplotlib.scale.get_scale_docs()` -- `matplotlib.pyplot.get_scale_docs()` +- ``matplotlib.scale.get_scale_docs()`` +- ``matplotlib.pyplot.get_scale_docs()`` These are considered internal and will be removed from the public API in a future version. @@ -905,7 +905,8 @@ Font Handling - ``backend_pdf.RendererPdf.afm_font_cache`` - ``backend_ps.RendererPS.afmfontd`` - ``font_manager.OSXInstalledFonts`` -- `.TextToPath.glyph_to_path` (Instead call ``font.get_path()`` and manually transform the path.) +- ``.TextToPath.glyph_to_path`` (Instead call ``font.get_path()`` and manually + transform the path.) Date related functions @@ -1011,7 +1012,7 @@ Path tools Use `~.path.get_path_collection_extents` instead. -- `.Path.has_nonfinite` attribute +- ``.Path.has_nonfinite`` attribute Use ``not np.isfinite(path.vertices).all()`` instead. diff --git a/doc/missing-references.json b/doc/missing-references.json index 80acaf840b16..d57405c036fe 100644 --- a/doc/missing-references.json +++ b/doc/missing-references.json @@ -1369,9 +1369,6 @@ "matplotlib.patches.Patch.__init__": [ "doc/devel/documenting_mpl.rst:696" ], - "matplotlib.pyplot.get_scale_docs()": [ - "doc/api/prev_api_changes/api_changes_3.1.0.rst:853" - ], "matplotlib.sphinxext.mathmpl": [ "doc/users/prev_whats_new/whats_new_3.0.rst:225" ], @@ -1543,4 +1540,4 @@ "lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.get_ylim3d:24" ] } -} \ No newline at end of file +} diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py index 500ab6e49477..ab531c3bd764 100644 --- a/lib/matplotlib/path.py +++ b/lib/matplotlib/path.py @@ -243,15 +243,6 @@ def simplify_threshold(self): def simplify_threshold(self, threshold): self._simplify_threshold = threshold - @cbook.deprecated( - "3.1", alternative="not np.isfinite(self.vertices).all()") - @property - def has_nonfinite(self): - """ - `True` if the vertices array has nonfinite values. - """ - return not np.isfinite(self._vertices).all() - @property def should_simplify(self): """ diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index c4fc3f4c0e34..3ee628e7278d 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -48,7 +48,7 @@ from matplotlib.axes import Axes, Subplot from matplotlib.projections import PolarAxes from matplotlib import mlab # for detrend_none, window_hanning -from matplotlib.scale import get_scale_docs, get_scale_names +from matplotlib.scale import get_scale_names from matplotlib import cm from matplotlib.cm import get_cmap, register_cmap diff --git a/lib/matplotlib/scale.py b/lib/matplotlib/scale.py index ae85d6914baa..1d8c56fa9a28 100644 --- a/lib/matplotlib/scale.py +++ b/lib/matplotlib/scale.py @@ -667,16 +667,6 @@ def register_scale(scale_class): _scale_mapping[scale_class.name] = scale_class -@cbook.deprecated( - '3.1', message='get_scale_docs() is considered private API since ' - '3.1 and will be removed from the public API in 3.3.') -def get_scale_docs(): - """ - Helper function for generating docstrings related to scales. - """ - return _get_scale_docs() - - def _get_scale_docs(): """ Helper function for generating docstrings related to scales. diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index f1c988370c6e..b7c89856641e 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -459,23 +459,3 @@ def _image_directories(func): result_dir = Path().resolve() / "result_images" / module_path.stem result_dir.mkdir(parents=True, exist_ok=True) return baseline_dir, result_dir - - -@cbook.deprecated("3.1", alternative="pytest.mark.backend") -def switch_backend(backend): - - def switch_backend_decorator(func): - - @functools.wraps(func) - def backend_switcher(*args, **kwargs): - try: - prev_backend = mpl.get_backend() - matplotlib.testing.setup() - plt.switch_backend(backend) - return func(*args, **kwargs) - finally: - plt.switch_backend(prev_backend) - - return backend_switcher - - return switch_backend_decorator diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py index 4daedaeb22eb..f47f1314cb10 100644 --- a/lib/matplotlib/textpath.py +++ b/lib/matplotlib/textpath.py @@ -51,16 +51,6 @@ def _get_char_id_ps(self, font, ccode): char_id = urllib.parse.quote('%s-%d' % (ps_name, ccode)) return char_id - @cbook.deprecated( - "3.1", - alternative="font.get_path() and manual translation of the vertices") - def glyph_to_path(self, font, currx=0.): - """Convert the *font*'s current glyph to a (vertices, codes) pair.""" - verts, codes = font.get_path() - if currx != 0.0: - verts[:, 0] += currx - return verts, codes - def get_text_width_height_descent(self, s, prop, ismath): if rcParams['text.usetex']: texmanager = self.get_texmanager() From ecae1329429468bd3c791ec75a97553056d754bc Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 19:24:42 -0400 Subject: [PATCH 05/10] Remove support for backends without set_hatch_color. --- doc/api/api_changes_3.3/removals.rst | 2 ++ lib/matplotlib/collections.py | 9 +-------- lib/matplotlib/patches.py | 9 +-------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/doc/api/api_changes_3.3/removals.rst b/doc/api/api_changes_3.3/removals.rst index 693cae71a229..508a883d1209 100644 --- a/doc/api/api_changes_3.3/removals.rst +++ b/doc/api/api_changes_3.3/removals.rst @@ -13,6 +13,8 @@ Classes, methods and attributes - ``axis.Axis.iter_ticks`` (no replacement) +- Support for custom backends that do not provide a + ``backend_bases.GraphicsContextBase.set_hatch_color`` method - ``backend_bases.RendererBase.strip_math()`` (use ``cbook.strip_math()`` instead) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 181e46b4584f..061b325b372e 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -302,14 +302,7 @@ def draw(self, renderer): if self._hatch: gc.set_hatch(self._hatch) - try: - gc.set_hatch_color(self._hatch_color) - except AttributeError: - # if we end up with a GC that does not have this method - cbook.warn_deprecated( - "3.1", message="Your backend does not support setting the " - "hatch color; such backends will become unsupported in " - "Matplotlib 3.3.") + gc.set_hatch_color(self._hatch_color) if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index a1e06c26172b..8f9756c47e5b 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -553,14 +553,7 @@ def _bind_draw_path_function(self, renderer): if self._hatch: gc.set_hatch(self._hatch) - try: - gc.set_hatch_color(self._hatch_color) - except AttributeError: - # if we end up with a GC that does not have this method - cbook.warn_deprecated( - "3.1", message="Your backend does not support setting the " - "hatch color; such backends will become unsupported in " - "Matplotlib 3.3.") + gc.set_hatch_color(self._hatch_color) if self.get_sketch_params() is not None: gc.set_sketch_params(*self.get_sketch_params()) From cd84080c80443027386d656c1985a7f0b5fcf78d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 19:44:14 -0400 Subject: [PATCH 06/10] Remove support for deprecated legend/table locations. --- doc/api/api_changes_3.3/behaviour.rst | 8 ++++++++ lib/matplotlib/legend.py | 25 ++++++------------------- lib/matplotlib/table.py | 7 ++----- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/doc/api/api_changes_3.3/behaviour.rst b/doc/api/api_changes_3.3/behaviour.rst index 17150d0e7973..60e8ae1b82ca 100644 --- a/doc/api/api_changes_3.3/behaviour.rst +++ b/doc/api/api_changes_3.3/behaviour.rst @@ -192,3 +192,11 @@ be kept by passing it as a keyword argument to `.Axes.hist`. `.Legend` and `.OffsetBox` subclasses (`.PaddedBox`, `.AnchoredOffsetbox`, and `.AnnotationBbox`) no longer directly keep track of the visibility of their underlying `.Patch` artist, but instead pass that flag down to the `.Patch`. + +`.Legend` and `.Table` no longer allow invalid locations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This affects legends produced on an Axes (`.Axes.legend` and `.pyplot.legend`) +and on a Figure (`.Figure.legend` and `.pyplot.figlegend`). Figure legends also +no longer accept the unsupported ``'best'`` location. Previously, invalid Axes +locations would use ``'best'`` and invalid Figure locations would used ``'upper +right'``. diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index 0b41e5261d14..6ab46e70bac9 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -444,28 +444,15 @@ def __init__(self, parent, handles, labels, loc = 'upper right' if isinstance(loc, str): if loc not in self.codes: - if self.isaxes: - cbook.warn_deprecated( - "3.1", message="Unrecognized location {!r}. Falling " - "back on 'best'; valid locations are\n\t{}\n" - "This will raise an exception %(removal)s." - .format(loc, '\n\t'.join(self.codes))) - loc = 0 - else: - cbook.warn_deprecated( - "3.1", message="Unrecognized location {!r}. Falling " - "back on 'upper right'; valid locations are\n\t{}\n'" - "This will raise an exception %(removal)s." - .format(loc, '\n\t'.join(self.codes))) - loc = 1 + raise ValueError( + "Unrecognized location {!r}. Valid locations are\n\t{}\n" + .format(loc, '\n\t'.join(self.codes))) else: loc = self.codes[loc] if not self.isaxes and loc == 0: - cbook.warn_deprecated( - "3.1", message="Automatic legend placement (loc='best') not " - "implemented for figure legend. Falling back on 'upper " - "right'. This will raise an exception %(removal)s.") - loc = 1 + raise ValueError( + "Automatic legend placement (loc='best') not implemented for " + "figure legend.") self._mode = mode self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform) diff --git a/lib/matplotlib/table.py b/lib/matplotlib/table.py index 94337489a882..25151e7679fa 100644 --- a/lib/matplotlib/table.py +++ b/lib/matplotlib/table.py @@ -293,12 +293,9 @@ def __init__(self, ax, loc=None, bbox=None, **kwargs): if isinstance(loc, str): if loc not in self.codes: - cbook.warn_deprecated( - "3.1", message="Unrecognized location {!r}. Falling back " - "on 'bottom'; valid locations are\n\t{}\n" - "This will raise an exception %(removal)s." + raise ValueError( + "Unrecognized location {!r}. Valid locations are\n\t{}" .format(loc, '\n\t'.join(self.codes))) - loc = 'bottom' loc = self.codes[loc] self.set_figure(ax.figure) self._axes = ax From e9eb00c7729fbadfdf6f1ad488bd4f5bef2441a4 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 19:51:12 -0400 Subject: [PATCH 07/10] Remove support for passing drawstyle in linestyle. --- doc/api/api_changes_3.3/behaviour.rst | 8 +++++ lib/matplotlib/lines.py | 47 --------------------------- 2 files changed, 8 insertions(+), 47 deletions(-) diff --git a/doc/api/api_changes_3.3/behaviour.rst b/doc/api/api_changes_3.3/behaviour.rst index 60e8ae1b82ca..7549920d1d35 100644 --- a/doc/api/api_changes_3.3/behaviour.rst +++ b/doc/api/api_changes_3.3/behaviour.rst @@ -200,3 +200,11 @@ and on a Figure (`.Figure.legend` and `.pyplot.figlegend`). Figure legends also no longer accept the unsupported ``'best'`` location. Previously, invalid Axes locations would use ``'best'`` and invalid Figure locations would used ``'upper right'``. + + +Passing Line2D's *drawstyle* together with *linestyle* is removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(..., +linestyle="--", drawstyle="steps")``. ``ds`` is also an alias for +``drawstyle``. diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index c13cc16ea44e..f5581476498b 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -335,16 +335,6 @@ def __init__(self, xdata, ydata, if solid_joinstyle is None: solid_joinstyle = rcParams['lines.solid_joinstyle'] - if isinstance(linestyle, str): - ds, ls = self._split_drawstyle_linestyle(linestyle) - if ds is not None and drawstyle is not None and ds != drawstyle: - raise ValueError("Inconsistent drawstyle ({!r}) and linestyle " - "({!r})".format(drawstyle, linestyle)) - linestyle = ls - - if ds is not None: - drawstyle = ds - if drawstyle is None: drawstyle = 'default' @@ -1102,39 +1092,6 @@ def set_linewidth(self, w): self._dashOffset, self._dashSeq = _scale_dashes( self._us_dashOffset, self._us_dashSeq, self._linewidth) - def _split_drawstyle_linestyle(self, ls): - """ - Split drawstyle from linestyle string. - - If *ls* is only a drawstyle default to returning a linestyle - of '-'. - - Parameters - ---------- - ls : str - The linestyle to be processed - - Returns - ------- - ret_ds : str or None - If the linestyle string does not contain a drawstyle prefix - return None, otherwise return it. - - ls : str - The linestyle with the drawstyle (if any) stripped. - """ - for ds in self.drawStyleKeys: # long names are first in the list - if ls.startswith(ds): - cbook.warn_deprecated( - "3.1", message="Passing the drawstyle with the linestyle " - "as a single string is deprecated since Matplotlib " - "%(since)s and support will be removed %(removal)s; " - "please pass the drawstyle separately using the drawstyle " - "keyword argument to Line2D or set_drawstyle() method (or " - "ds/set_ds()).") - return ds, ls[len(ds):] or '-' - return None, ls - def set_linestyle(self, ls): """ Set the linestyle of the line. @@ -1167,10 +1124,6 @@ def set_linestyle(self, ls): For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`. """ if isinstance(ls, str): - ds, ls = self._split_drawstyle_linestyle(ls) - if ds is not None: - self.set_drawstyle(ds) - if ls in [' ', '', 'none']: ls = 'None' From 462eb5fa6af9c2269b8b92ba9a01839b328e9bd4 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 23:28:44 -0400 Subject: [PATCH 08/10] Remove support for upper case color strings. --- doc/api/api_changes_3.3/behaviour.rst | 6 ++++++ lib/matplotlib/colors.py | 16 +++++----------- lib/matplotlib/tests/test_axes.py | 8 -------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/doc/api/api_changes_3.3/behaviour.rst b/doc/api/api_changes_3.3/behaviour.rst index 7549920d1d35..70a02d81b9d4 100644 --- a/doc/api/api_changes_3.3/behaviour.rst +++ b/doc/api/api_changes_3.3/behaviour.rst @@ -208,3 +208,9 @@ Passing Line2D's *drawstyle* together with *linestyle* is removed Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(..., linestyle="--", drawstyle="steps")``. ``ds`` is also an alias for ``drawstyle``. + +Upper case color strings +~~~~~~~~~~~~~~~~~~~~~~~~ + +Support for passing single-letter colors (one of "rgbcmykw") as UPPERCASE +characters is removed; these colors are now case-sensitive (lowercase). diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index d461768d737d..ad88ea6052d8 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -198,17 +198,11 @@ def _to_rgba_no_colorcycle(c, alpha=None): # This may turn c into a non-string, so we check again below. c = _colors_full_map[c] except KeyError: - try: - c = _colors_full_map[c.lower()] - except KeyError: - pass - else: - if len(orig_c) == 1: - cbook.warn_deprecated( - "3.1", message="Support for uppercase " - "single-letter colors is deprecated since Matplotlib " - "%(since)s and will be removed %(removal)s; please " - "use lowercase instead.") + if len(orig_c) != 1: + try: + c = _colors_full_map[c.lower()] + except KeyError: + pass if isinstance(c, str): # hex color in #rrggbb format. match = re.match(r"\A#[a-fA-F0-9]{6}\Z", c) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 53bc10b15b3d..030615286461 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5650,14 +5650,6 @@ def test_annotate_across_transforms(): arrowprops=dict(arrowstyle="->")) -def test_deprecated_uppercase_colors(): - # Remove after end of deprecation period. - fig, ax = plt.subplots() - with pytest.warns(MatplotlibDeprecationWarning): - ax.plot([1, 2], color="B") - fig.canvas.draw() - - @image_comparison(['secondary_xy.png'], style='mpl20') def test_secondary_xy(): fig, axs = plt.subplots(1, 2, figsize=(10, 5), constrained_layout=True) From 66bfc0068ccb3c98f41a56e2ea704e88c89df22e Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Apr 2020 23:30:50 -0400 Subject: [PATCH 09/10] Remove support for non-1D input to Axes.pie. --- doc/api/api_changes_3.3/removals.rst | 2 ++ lib/matplotlib/axes/_axes.py | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/api/api_changes_3.3/removals.rst b/doc/api/api_changes_3.3/removals.rst index 508a883d1209..144b38dbc31e 100644 --- a/doc/api/api_changes_3.3/removals.rst +++ b/doc/api/api_changes_3.3/removals.rst @@ -219,6 +219,8 @@ Arguments ``connector`` keyword arguments, which did nothing since 3.0. - `.TextPath` no longer accepts arbitrary positional or keyword arguments. - `.MaxNLocator.set_params()` no longer accepts arbitrary keyword arguments. +- `~.Axes.pie` no longer accepts and squeezes non-1D inputs; pass 1D input to + the ``x`` argument. rcParams ~~~~~~~~ diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 63b16c311810..31ad2fc11812 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2915,7 +2915,7 @@ def pie(self, x, explode=None, labels=None, colors=None, Parameters ---------- - x : array-like + x : 1D array-like The wedge sizes. explode : array-like, default: None @@ -2999,12 +2999,8 @@ def pie(self, x, explode=None, labels=None, colors=None, # The use of float32 is "historical", but can't be changed without # regenerating the test baselines. x = np.asarray(x, np.float32) - if x.ndim != 1 and x.squeeze().ndim <= 1: - cbook.warn_deprecated( - "3.1", message="Non-1D inputs to pie() are currently " - "squeeze()d, but this behavior is deprecated since %(since)s " - "and will be removed %(removal)s; pass a 1D array instead.") - x = np.atleast_1d(x.squeeze()) + if x.ndim > 1: + raise ValueError("x must be 1D") if np.any(x < 0): raise ValueError("Wedge sizes 'x' must be non negative values") From a30e8e76ca958d06d997d43980f6a6e1c7b134fc Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 25 Apr 2020 00:02:04 -0400 Subject: [PATCH 10/10] Remove support for non-1D errorbars. --- doc/api/api_changes_3.3/removals.rst | 2 ++ lib/matplotlib/axes/_axes.py | 21 +++++---------------- lib/matplotlib/tests/test_axes.py | 14 ++++---------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/doc/api/api_changes_3.3/removals.rst b/doc/api/api_changes_3.3/removals.rst index 144b38dbc31e..3f7c232e9800 100644 --- a/doc/api/api_changes_3.3/removals.rst +++ b/doc/api/api_changes_3.3/removals.rst @@ -221,6 +221,8 @@ Arguments - `.MaxNLocator.set_params()` no longer accepts arbitrary keyword arguments. - `~.Axes.pie` no longer accepts and squeezes non-1D inputs; pass 1D input to the ``x`` argument. +- Passing (n, 1)-shaped error arrays to `.Axes.errorbar()` is no longer + supported; pass a 1D array instead. rcParams ~~~~~~~~ diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 31ad2fc11812..9b821b1f94e5 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3368,7 +3368,7 @@ def xywhere(xs, ys, mask): ys = [thisy for thisy, b in zip(ys, mask) if b] return xs, ys - def extract_err(err, data): + def extract_err(name, err, data): """ Private function to parse *err* and subtract/add it to *data*. @@ -3380,20 +3380,9 @@ def extract_err(err, data): iter(b) except (TypeError, ValueError): a = b = err # Symmetric error: 1D iterable. - # This could just be `np.ndim(a) > 1 and np.ndim(b) > 1`, except - # for the (undocumented, but tested) support for (n, 1) arrays. - a_sh = np.shape(a) - b_sh = np.shape(b) - if (len(a_sh) > 2 or (len(a_sh) == 2 and a_sh[1] != 1) - or len(b_sh) > 2 or (len(b_sh) == 2 and b_sh[1] != 1)): + if np.ndim(a) > 1 or np.ndim(b) > 1: raise ValueError( - "err must be a scalar or a 1D or (2, n) array-like") - if len(a_sh) == 2 or len(b_sh) == 2: - cbook.warn_deprecated( - "3.1", message="Support for passing a (n, 1)-shaped error " - "array to errorbar() is deprecated since Matplotlib " - "%(since)s and will be removed %(removal)s; pass a 1D " - "array instead.") + f"{name}err must be a scalar or a 1D or (2, n) array-like") # Using list comprehensions rather than arrays to preserve units. for e in [a, b]: if len(data) != len(e): @@ -3405,7 +3394,7 @@ def extract_err(err, data): return low, high if xerr is not None: - left, right = extract_err(xerr, x) + left, right = extract_err('x', xerr, x) # select points without upper/lower limits in x and # draw normal errorbars for these points noxlims = ~(xlolims | xuplims) @@ -3454,7 +3443,7 @@ def extract_err(err, data): **eb_cap_style)) if yerr is not None: - lower, upper = extract_err(yerr, y) + lower, upper = extract_err('y', yerr, y) # select points without upper/lower limits in y and # draw normal errorbars for these points noylims = ~(lolims | uplims) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 030615286461..faf024a02512 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2855,9 +2855,7 @@ def test_errorbar(): # Now switch to a more OO interface to exercise more features. fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True) ax = axs[0, 0] - # Try a Nx1 shaped error just to check - with pytest.warns(MatplotlibDeprecationWarning): - ax.errorbar(x, y, yerr=np.reshape(yerr, (len(y), 1)), fmt='o') + ax.errorbar(x, y, yerr=yerr, fmt='o') ax.set_title('Vert. symmetric') # With 4 subplots, reduce the number of axis ticks to avoid crowding. @@ -4754,10 +4752,8 @@ def generate_errorbar_inputs(): [1, 1, 1, 1, 1], [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]], - [[1]] * 5, np.ones(5), np.ones((2, 5)), - np.ones((5, 1)), None ]) xerr_cy = cycler('xerr', err_cycler) @@ -4774,11 +4770,9 @@ def generate_errorbar_inputs(): @pytest.mark.parametrize('kwargs', generate_errorbar_inputs()) def test_errorbar_inputs_shotgun(kwargs): - # (n, 1)-shaped error deprecation already tested by test_errorbar. - with mpl.cbook._suppress_matplotlib_deprecation_warning(): - ax = plt.gca() - eb = ax.errorbar(**kwargs) - eb.remove() + ax = plt.gca() + eb = ax.errorbar(**kwargs) + eb.remove() @image_comparison(["dash_offset"], remove_text=True)