From 8e59326b6d22fc4c360be3d3b72ac34c9e0240fa Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 12:43:22 +0100 Subject: [PATCH 01/35] Unify pickradius arguments and checking --- lib/matplotlib/axis.py | 3 +-- lib/matplotlib/collections.py | 4 +++- lib/matplotlib/lines.py | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index b0a70b5346ac..bd767f2717f3 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -640,8 +640,7 @@ def __str__(self): return "{}({},{})".format( type(self).__name__, *self.axes.transAxes.transform((0, 0))) - @_api.make_keyword_only("3.6", name="pickradius") - def __init__(self, axes, pickradius=15): + def __init__(self, axes, *, pickradius=15): """ Parameters ---------- diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 3aa2eba48ff2..d951fe79dd59 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -433,7 +433,6 @@ def draw(self, renderer): renderer.close_group(self.__class__.__name__) self.stale = False - @_api.rename_parameter("3.6", "pr", "pickradius") def set_pickradius(self, pickradius): """ Set the pick radius used for containment tests. @@ -443,6 +442,9 @@ def set_pickradius(self, pickradius): pickradius : float Pick radius, in points. """ + if not isinstance(pickradius, Number): + raise ValueError( + f"pickradius must be a number, not {pickradius!r}") self._pickradius = pickradius def get_pickradius(self): diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index a165ef3c994a..2cc3d24a3e2d 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -404,7 +404,7 @@ def __init__(self, xdata, ydata, # update kwargs before updating data to give the caller a # chance to init axes (and hence unit support) self._internal_update(kwargs) - self._pickradius = pickradius + self.pickradius = pickradius self.ind_offset = 0 if (isinstance(self._picker, Number) and not isinstance(self._picker, bool)): @@ -502,7 +502,6 @@ def get_pickradius(self): """ return self._pickradius - @_api.rename_parameter("3.6", "d", "pickradius") def set_pickradius(self, pickradius): """ Set the pick radius used for containment tests. From c6491af77bae9ad192b82a3ac226cfcc5815382b Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 12:55:08 +0100 Subject: [PATCH 02/35] Remove date_ticker_factory --- lib/matplotlib/dates.py | 45 ------------------------------ lib/matplotlib/tests/test_dates.py | 13 --------- 2 files changed, 58 deletions(-) diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 4b7e5a99a77f..8f729bff7992 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -172,7 +172,6 @@ import datetime import functools import logging -import math import re from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, @@ -1777,50 +1776,6 @@ def _get_interval(self): return self._interval -@_api.deprecated("3.6", alternative="`AutoDateLocator` and `AutoDateFormatter`" - " or vendor the code") -def date_ticker_factory(span, tz=None, numticks=5): - """ - Create a date locator with *numticks* (approx) and a date formatter - for *span* in days. Return value is (locator, formatter). - """ - - if span == 0: - span = 1 / HOURS_PER_DAY - - mins = span * MINUTES_PER_DAY - hrs = span * HOURS_PER_DAY - days = span - wks = span / DAYS_PER_WEEK - months = span / DAYS_PER_MONTH # Approx - years = span / DAYS_PER_YEAR # Approx - - if years > numticks: - locator = YearLocator(int(years / numticks), tz=tz) # define - fmt = '%Y' - elif months > numticks: - locator = MonthLocator(tz=tz) - fmt = '%b %Y' - elif wks > numticks: - locator = WeekdayLocator(tz=tz) - fmt = '%a, %b %d' - elif days > numticks: - locator = DayLocator(interval=math.ceil(days / numticks), tz=tz) - fmt = '%b %d' - elif hrs > numticks: - locator = HourLocator(interval=math.ceil(hrs / numticks), tz=tz) - fmt = '%H:%M\n%b %d' - elif mins > numticks: - locator = MinuteLocator(interval=math.ceil(mins / numticks), tz=tz) - fmt = '%H:%M:%S' - else: - locator = MinuteLocator(tz=tz) - fmt = '%H:%M:%S' - - formatter = DateFormatter(fmt, tz=tz) - return locator, formatter - - class DateConverter(units.ConversionInterface): """ Converter for `datetime.date` and `datetime.datetime` data, or for diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index cc9a83a5c5b6..bfd7f4ae062d 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -1371,19 +1371,6 @@ def test_concise_formatter_call(): assert formatter.format_data_short(19002.0) == '2022-01-10 00:00:00' -@pytest.mark.parametrize('span, expected_locator', - ((0.02, mdates.MinuteLocator), - (1, mdates.HourLocator), - (19, mdates.DayLocator), - (40, mdates.WeekdayLocator), - (200, mdates.MonthLocator), - (2000, mdates.YearLocator))) -def test_date_ticker_factory(span, expected_locator): - with pytest.warns(_api.MatplotlibDeprecationWarning): - locator, _ = mdates.date_ticker_factory(span) - assert isinstance(locator, expected_locator) - - def test_datetime_masked(): # make sure that all-masked data falls back to the viewlim # set in convert.axisinfo.... From 79e7e8bbbf9b4fdeebf7e7109ca67fbdfb58d987 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 12:56:40 +0100 Subject: [PATCH 03/35] Remove checkdep_usetex --- lib/matplotlib/__init__.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 5583dc1b3f23..53a3ab03980f 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -462,26 +462,6 @@ def impl(args, regex, min_ver=None, ignore_exit_code=False): raise ValueError(f"Unknown executable: {name!r}") -@_api.deprecated("3.6", alternative="a vendored copy of this function") -def checkdep_usetex(s): - if not s: - return False - if not shutil.which("tex"): - _log.warning("usetex mode requires TeX.") - return False - try: - _get_executable_info("dvipng") - except ExecutableNotFoundError: - _log.warning("usetex mode requires dvipng.") - return False - try: - _get_executable_info("gs") - except ExecutableNotFoundError: - _log.warning("usetex mode requires ghostscript.") - return False - return True - - def _get_xdg_config_dir(): """ Return the XDG configuration directory, according to the XDG base From 9aa564cab59ad94c5dd977d9865a15e18a8f6ad5 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:24:15 +0100 Subject: [PATCH 04/35] Expire deprecations --- lib/matplotlib/_mathtext.py | 15 +--- lib/matplotlib/axis.py | 61 --------------- lib/matplotlib/mathtext.py | 151 +----------------------------------- lib/matplotlib/ticker.py | 68 ++-------------- 4 files changed, 9 insertions(+), 286 deletions(-) diff --git a/lib/matplotlib/_mathtext.py b/lib/matplotlib/_mathtext.py index b41dca9d6988..1c4a37cef9b3 100644 --- a/lib/matplotlib/_mathtext.py +++ b/lib/matplotlib/_mathtext.py @@ -20,7 +20,7 @@ pyparsing_common) import matplotlib as mpl -from . import _api, cbook +from . import cbook from ._mathtext_data import ( latex_to_bakoma, stix_glyph_fixes, stix_virtual_fonts, tex2uni) from .font_manager import FontProperties, findfont, get_font @@ -35,8 +35,7 @@ # FONTS -@_api.delete_parameter("3.6", "math") -def get_unicode_index(symbol, math=False): # Publicly exported. +def get_unicode_index(symbol): # Publicly exported. r""" Return the integer index (from the Unicode table) of *symbol*. @@ -45,17 +44,7 @@ def get_unicode_index(symbol, math=False): # Publicly exported. symbol : str A single (Unicode) character, a TeX command (e.g. r'\pi') or a Type1 symbol name (e.g. 'phi'). - math : bool, default: False - If True (deprecated), replace ASCII hyphen-minus by Unicode minus. """ - # From UTF #25: U+2212 minus sign is the preferred - # representation of the unary and binary minus sign rather than - # the ASCII-derived U+002D hyphen-minus, because minus sign is - # unambiguous and because it is rendered with a more desirable - # length, usually longer than a hyphen. - # Remove this block when the 'math' parameter is deleted. - if math and symbol == '-': - return 0x2212 try: # This will succeed if symbol is a single Unicode char return ord(symbol) except TypeError: diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index bd767f2717f3..31ad88595f0b 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -240,10 +240,6 @@ def set_clip_path(self, clippath, transform=None): self.gridline.set_clip_path(clippath, transform) self.stale = True - @_api.deprecated("3.6") - def get_pad_pixels(self): - return self.figure.dpi * self._base_pad / 72 - def contains(self, mouseevent): """ Test whether the mouse event occurred in the Tick marks. @@ -1250,21 +1246,6 @@ def _set_artist_props(self, a): return a.set_figure(self.figure) - @_api.deprecated("3.6") - def get_ticklabel_extents(self, renderer): - """Get the extents of the tick labels on either side of the axes.""" - ticks_to_draw = self._update_ticks() - tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer) - if len(tlb1): - bbox1 = mtransforms.Bbox.union(tlb1) - else: - bbox1 = mtransforms.Bbox.from_extents(0, 0, 0, 0) - if len(tlb2): - bbox2 = mtransforms.Bbox.union(tlb2) - else: - bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0) - return bbox1, bbox2 - def _update_ticks(self): """ Update ticks (position and labels) using the current data interval of @@ -2350,29 +2331,6 @@ def _update_offset_text_position(self, bboxes, bboxes2): y = top + self.OFFSETTEXTPAD * self.figure.dpi / 72 self.offsetText.set_position((x, y)) - @_api.deprecated("3.6") - def get_text_heights(self, renderer): - """ - Return how much space should be reserved for text above and below the - Axes, as a pair of floats. - """ - bbox, bbox2 = self.get_ticklabel_extents(renderer) - # MGDTODO: Need a better way to get the pad - pad_pixels = self.majorTicks[0].get_pad_pixels() - - above = 0.0 - if bbox2.height: - above += bbox2.height + pad_pixels - below = 0.0 - if bbox.height: - below += bbox.height + pad_pixels - - if self.get_label_position() == 'top': - above += self.label.get_window_extent(renderer).height + pad_pixels - else: - below += self.label.get_window_extent(renderer).height + pad_pixels - return above, below - def set_ticks_position(self, position): """ Set the ticks position. @@ -2621,25 +2579,6 @@ def set_offset_position(self, position): self.offsetText.set_position((x, y)) self.stale = True - @_api.deprecated("3.6") - def get_text_widths(self, renderer): - bbox, bbox2 = self.get_ticklabel_extents(renderer) - # MGDTODO: Need a better way to get the pad - pad_pixels = self.majorTicks[0].get_pad_pixels() - - left = 0.0 - if bbox.width: - left += bbox.width + pad_pixels - right = 0.0 - if bbox2.width: - right += bbox2.width + pad_pixels - - if self.get_label_position() == 'left': - left += self.label.get_window_extent(renderer).width + pad_pixels - else: - right += self.label.get_window_extent(renderer).width + pad_pixels - return left, right - def set_ticks_position(self, position): """ Set the ticks position. diff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py index fc677e83616e..276edf5c764e 100644 --- a/lib/matplotlib/mathtext.py +++ b/lib/matplotlib/mathtext.py @@ -15,15 +15,11 @@ metrics for those fonts. """ -from collections import namedtuple import functools import logging -import numpy as np - -import matplotlib as mpl from matplotlib import _api, _mathtext -from matplotlib.ft2font import FT2Image, LOAD_NO_HINTING +from matplotlib.ft2font import LOAD_NO_HINTING from matplotlib.font_manager import FontProperties from ._mathtext import ( # noqa: reexported API RasterParse, VectorParse, get_unicode_index) @@ -33,151 +29,6 @@ get_unicode_index.__module__ = __name__ - -@_api.deprecated("3.6") -class MathtextBackend: - """ - The base class for the mathtext backend-specific code. `MathtextBackend` - subclasses interface between mathtext and specific Matplotlib graphics - backends. - - Subclasses need to override the following: - - - :meth:`render_glyph` - - :meth:`render_rect_filled` - - :meth:`get_results` - - And optionally, if you need to use a FreeType hinting style: - - - :meth:`get_hinting_type` - """ - def __init__(self): - self.width = 0 - self.height = 0 - self.depth = 0 - - def set_canvas_size(self, w, h, d): - """Set the dimension of the drawing canvas.""" - self.width = w - self.height = h - self.depth = d - - def render_glyph(self, ox, oy, info): - """ - Draw a glyph described by *info* to the reference point (*ox*, - *oy*). - """ - raise NotImplementedError() - - def render_rect_filled(self, x1, y1, x2, y2): - """ - Draw a filled black rectangle from (*x1*, *y1*) to (*x2*, *y2*). - """ - raise NotImplementedError() - - def get_results(self, box): - """ - Return a backend-specific tuple to return to the backend after - all processing is done. - """ - raise NotImplementedError() - - def get_hinting_type(self): - """ - Get the FreeType hinting type to use with this particular - backend. - """ - return LOAD_NO_HINTING - - -@_api.deprecated("3.6") -class MathtextBackendAgg(MathtextBackend): - """ - Render glyphs and rectangles to an FTImage buffer, which is later - transferred to the Agg image by the Agg backend. - """ - def __init__(self): - self.ox = 0 - self.oy = 0 - self.image = None - self.mode = 'bbox' - self.bbox = [0, 0, 0, 0] - super().__init__() - - def _update_bbox(self, x1, y1, x2, y2): - self.bbox = [min(self.bbox[0], x1), - min(self.bbox[1], y1), - max(self.bbox[2], x2), - max(self.bbox[3], y2)] - - def set_canvas_size(self, w, h, d): - super().set_canvas_size(w, h, d) - if self.mode != 'bbox': - self.image = FT2Image(np.ceil(w), np.ceil(h + max(d, 0))) - - def render_glyph(self, ox, oy, info): - if self.mode == 'bbox': - self._update_bbox(ox + info.metrics.xmin, - oy - info.metrics.ymax, - ox + info.metrics.xmax, - oy - info.metrics.ymin) - else: - info.font.draw_glyph_to_bitmap( - self.image, ox, oy - info.metrics.iceberg, info.glyph, - antialiased=mpl.rcParams['text.antialiased']) - - def render_rect_filled(self, x1, y1, x2, y2): - if self.mode == 'bbox': - self._update_bbox(x1, y1, x2, y2) - else: - height = max(int(y2 - y1) - 1, 0) - if height == 0: - center = (y2 + y1) / 2.0 - y = int(center - (height + 1) / 2.0) - else: - y = int(y1) - self.image.draw_rect_filled(int(x1), y, np.ceil(x2), y + height) - - def get_results(self, box): - self.image = None - self.mode = 'render' - return _mathtext.ship(box).to_raster() - - def get_hinting_type(self): - from matplotlib.backends import backend_agg - return backend_agg.get_hinting_flag() - - -@_api.deprecated("3.6") -class MathtextBackendPath(MathtextBackend): - """ - Store information to write a mathtext rendering to the text path - machinery. - """ - - _Result = namedtuple("_Result", "width height depth glyphs rects") - - def __init__(self): - super().__init__() - self.glyphs = [] - self.rects = [] - - def render_glyph(self, ox, oy, info): - oy = self.height - oy + info.offset - self.glyphs.append((info.font, info.fontsize, info.num, ox, oy)) - - def render_rect_filled(self, x1, y1, x2, y2): - self.rects.append((x1, self.height - y2, x2 - x1, y2 - y1)) - - def get_results(self, box): - return _mathtext.ship(box).to_vector() - - -@_api.deprecated("3.6") -class MathTextWarning(Warning): - pass - - ############################################################################## # MAIN diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 9a3f047eb79d..339a8c6d9293 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -154,32 +154,25 @@ class _DummyAxis: __name__ = "dummy" - # Once the deprecation elapses, replace dataLim and viewLim by plain - # _view_interval and _data_interval private tuples. - dataLim = _api.deprecate_privatize_attribute( - "3.6", alternative="get_data_interval() and set_data_interval()") - viewLim = _api.deprecate_privatize_attribute( - "3.6", alternative="get_view_interval() and set_view_interval()") - def __init__(self, minpos=0): - self._dataLim = mtransforms.Bbox.unit() - self._viewLim = mtransforms.Bbox.unit() + self._data_interval = (0, 1) + self._view_interval = (0, 1) self._minpos = minpos def get_view_interval(self): - return self._viewLim.intervalx + return self._view_interval def set_view_interval(self, vmin, vmax): - self._viewLim.intervalx = vmin, vmax + self._view_interval = (vmin, vmax) def get_minpos(self): return self._minpos def get_data_interval(self): - return self._dataLim.intervalx + return self._data_interval def set_data_interval(self, vmin, vmax): - self._dataLim.intervalx = vmin, vmax + self._data_interval = (vmin, vmax) def get_tick_space(self): # Just use the long-standing default of nbins==9 @@ -882,16 +875,6 @@ def __init__(self, base=10.0, labelOnlyBase=False, self._sublabels = None self._linthresh = linthresh - @_api.deprecated("3.6", alternative='set_base()') - def base(self, base): - """ - Change the *base* for labeling. - - .. warning:: - Should always match the base used for :class:`LogLocator` - """ - self.set_base(base) - def set_base(self, base): """ Change the *base* for labeling. @@ -901,18 +884,6 @@ def set_base(self, base): """ self._base = float(base) - @_api.deprecated("3.6", alternative='set_label_minor()') - def label_minor(self, labelOnlyBase): - """ - Switch minor tick labeling on or off. - - Parameters - ---------- - labelOnlyBase : bool - If True, label ticks only at integer powers of base. - """ - self.set_label_minor(labelOnlyBase) - def set_label_minor(self, labelOnlyBase): """ Switch minor tick labeling on or off. @@ -2169,16 +2140,6 @@ def view_limits(self, dmin, dmax): return dmin, dmax -@_api.deprecated("3.6") -def is_decade(x, base=10, *, rtol=1e-10): - if not np.isfinite(x): - return False - if x == 0.0: - return True - lx = np.log(abs(x)) / np.log(base) - return is_close_to_int(lx, atol=rtol) - - def _is_decade(x, *, base=10, rtol=None): """Return True if *x* is an integer power of *base*.""" if not np.isfinite(x): @@ -2242,11 +2203,6 @@ def _decade_greater(x, base): return greater -@_api.deprecated("3.6") -def is_close_to_int(x, *, atol=1e-10): - return abs(x - np.round(x)) < atol - - def _is_close_to_int(x): return math.isclose(x, round(x)) @@ -2305,18 +2261,6 @@ def set_params(self, base=None, subs=None, numdecs=None, numticks=None): if numticks is not None: self.numticks = numticks - @_api.deprecated("3.6", alternative='set_params(base=...)') - def base(self, base): - """Set the log base (major tick every ``base**i``, i integer).""" - self._base = float(base) - - @_api.deprecated("3.6", alternative='set_params(subs=...)') - def subs(self, subs): - """ - Set the minor ticks for the log scaling every ``base**i*subs[j]``. - """ - self._set_subs(subs) - def _set_subs(self, subs): """ Set the minor ticks for the log scaling every ``base**i*subs[j]``. From e5a456b1cbb538d42cba68bd68e77152e4b99f95 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 13:51:26 +0100 Subject: [PATCH 05/35] Remove stride_windows --- lib/matplotlib/mlab.py | 48 ++----------------------------- lib/matplotlib/tests/test_mlab.py | 43 +++++++++------------------ 2 files changed, 16 insertions(+), 75 deletions(-) diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index efa2f84cae4b..a38e11a53bf5 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -213,8 +213,7 @@ def detrend_linear(y): return y - (b*x + a) -@_api.deprecated("3.6") -def stride_windows(x, n, noverlap=None, axis=0): +def _stride_windows(x, n, noverlap=0): """ Get all windows of *x* with length *n* as a single array, using strides to avoid data duplication. @@ -233,8 +232,6 @@ def stride_windows(x, n, noverlap=None, axis=0): The number of data points in each window. noverlap : int, default: 0 (no overlap) The overlap between adjacent windows. - axis : int - The axis along which the windows will run. References ---------- @@ -243,49 +240,10 @@ def stride_windows(x, n, noverlap=None, axis=0): `stackoverflow: Using strides for an efficient moving average filter `_ """ - if noverlap is None: - noverlap = 0 - if np.ndim(x) != 1: - raise ValueError('only 1-dimensional arrays can be used') - return _stride_windows(x, n, noverlap, axis) - - -def _stride_windows(x, n, noverlap=0, axis=0): - # np>=1.20 provides sliding_window_view, and we only ever use axis=0. - if hasattr(np.lib.stride_tricks, "sliding_window_view") and axis == 0: - if noverlap >= n: - raise ValueError('noverlap must be less than n') - return np.lib.stride_tricks.sliding_window_view( - x, n, axis=0)[::n - noverlap].T - if noverlap >= n: raise ValueError('noverlap must be less than n') - if n < 1: - raise ValueError('n cannot be less than 1') - - x = np.asarray(x) - - if n == 1 and noverlap == 0: - if axis == 0: - return x[np.newaxis] - else: - return x[np.newaxis].T - if n > x.size: - raise ValueError('n cannot be greater than the length of x') - - # np.lib.stride_tricks.as_strided easily leads to memory corruption for - # non integer shape and strides, i.e. noverlap or n. See #3845. - noverlap = int(noverlap) - n = int(n) - - step = n - noverlap - if axis == 0: - shape = (n, (x.shape[-1]-noverlap)//step) - strides = (x.strides[0], step*x.strides[0]) - else: - shape = ((x.shape[-1]-noverlap)//step, n) - strides = (step*x.strides[0], x.strides[0]) - return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides) + return np.lib.stride_tricks.sliding_window_view( + x, n, axis=0)[::n - noverlap].T def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, diff --git a/lib/matplotlib/tests/test_mlab.py b/lib/matplotlib/tests/test_mlab.py index 9cd1b44cc1e2..7f57f6f8c999 100644 --- a/lib/matplotlib/tests/test_mlab.py +++ b/lib/matplotlib/tests/test_mlab.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from matplotlib import mlab, _api +from matplotlib import mlab class TestStride: @@ -13,12 +13,7 @@ def get_base(self, x): y = y.base return y - @pytest.fixture(autouse=True) - def stride_is_deprecated(self): - with _api.suppress_matplotlib_deprecation_warning(): - yield - - def calc_window_target(self, x, NFFT, noverlap=0, axis=0): + def calc_window_target(self, x, NFFT, noverlap=0): """ This is an adaptation of the original window extraction algorithm. This is here to test to make sure the new implementation has the same @@ -32,55 +27,43 @@ def calc_window_target(self, x, NFFT, noverlap=0, axis=0): # do the ffts of the slices for i in range(n): result[:, i] = x[ind[i]:ind[i]+NFFT] - if axis == 1: - result = result.T return result - @pytest.mark.parametrize('shape', [(), (10, 1)], ids=['0D', '2D']) - def test_stride_windows_invalid_input_shape(self, shape): - x = np.arange(np.prod(shape)).reshape(shape) - with pytest.raises(ValueError): - mlab.stride_windows(x, 5) - @pytest.mark.parametrize('n, noverlap', - [(0, None), (11, None), (2, 2), (2, 3)], - ids=['n less than 1', 'n greater than input', - 'noverlap greater than n', + [(2, 2), (2, 3)], + ids=['noverlap greater than n', 'noverlap equal to n']) def test_stride_windows_invalid_params(self, n, noverlap): x = np.arange(10) with pytest.raises(ValueError): - mlab.stride_windows(x, n, noverlap) + mlab._stride_windows(x, n, noverlap) - @pytest.mark.parametrize('axis', [0, 1], ids=['axis0', 'axis1']) @pytest.mark.parametrize('n, noverlap', [(1, 0), (5, 0), (15, 2), (13, -3)], ids=['n1-noverlap0', 'n5-noverlap0', 'n15-noverlap2', 'n13-noverlapn3']) - def test_stride_windows(self, n, noverlap, axis): + def test_stride_windows(self, n, noverlap): x = np.arange(100) - y = mlab.stride_windows(x, n, noverlap=noverlap, axis=axis) + y = mlab._stride_windows(x, n, noverlap=noverlap) expected_shape = [0, 0] - expected_shape[axis] = n - expected_shape[1 - axis] = 100 // (n - noverlap) - yt = self.calc_window_target(x, n, noverlap=noverlap, axis=axis) + expected_shape[0] = n + expected_shape[1] = 100 // (n - noverlap) + yt = self.calc_window_target(x, n, noverlap=noverlap) assert yt.shape == y.shape assert_array_equal(yt, y) assert tuple(expected_shape) == y.shape assert self.get_base(y) is x - @pytest.mark.parametrize('axis', [0, 1], ids=['axis0', 'axis1']) - def test_stride_windows_n32_noverlap0_unflatten(self, axis): + def test_stride_windows_n32_noverlap0_unflatten(self): n = 32 x = np.arange(n)[np.newaxis] x1 = np.tile(x, (21, 1)) x2 = x1.flatten() - y = mlab.stride_windows(x2, n, axis=axis) + y = mlab._stride_windows(x2, n) - if axis == 0: - x1 = x1.T + x1 = x1.T assert y.shape == x1.shape assert_array_equal(y, x1) From ead1c179a71f3ecf419826d4e46c465af0554202 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 13:53:33 +0100 Subject: [PATCH 06/35] Make most arguments to Line2D keyword only --- lib/matplotlib/lines.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 2cc3d24a3e2d..902c68095f8f 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -282,8 +282,7 @@ def __str__(self): return "Line2D(%s)" % ",".join( map("({:g},{:g})".format, self._x, self._y)) - @_api.make_keyword_only("3.6", name="linewidth") - def __init__(self, xdata, ydata, + def __init__(self, xdata, ydata, *, linewidth=None, # all Nones default to rc linestyle=None, color=None, From 49d5ef921807100d90477c721121d71d1e3d326d Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 13:56:20 +0100 Subject: [PATCH 07/35] Remove get_font_config --- lib/matplotlib/texmanager.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index 7f790d9e0fa9..b920e66def49 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -31,7 +31,7 @@ import numpy as np import matplotlib as mpl -from matplotlib import _api, cbook, dviread +from matplotlib import cbook, dviread _log = logging.getLogger(__name__) @@ -105,15 +105,6 @@ def __new__(cls): Path(cls.texcache).mkdir(parents=True, exist_ok=True) return object.__new__(cls) - @_api.deprecated("3.6") - def get_font_config(self): - preamble, font_cmd = self._get_font_preamble_and_command() - # Add a hash of the latex preamble to fontconfig so that the - # correct png is selected for strings rendered with same font and dpi - # even if the latex preamble changes within the session - preambles = preamble + font_cmd + self.get_custom_preamble() - return hashlib.md5(preambles.encode('utf-8')).hexdigest() - @classmethod def _get_font_family_and_reduced(cls): """Return the font family name and whether the font is reduced.""" From c2f97a713ff8c6557cf8b4470f76473ce1bcc3ce Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 13:57:14 +0100 Subject: [PATCH 08/35] Make most arguments to Text keyword only --- lib/matplotlib/text.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index f1e300b838e2..24545edc2e8e 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -129,9 +129,8 @@ class Text(Artist): def __repr__(self): return f"Text({self._x}, {self._y}, {self._text!r})" - @_api.make_keyword_only("3.6", name="color") def __init__(self, - x=0, y=0, text='', + x=0, y=0, text='', *, color=None, # defaults to rc params verticalalignment='baseline', horizontalalignment='left', @@ -143,7 +142,6 @@ def __init__(self, usetex=None, # defaults to rcParams['text.usetex'] wrap=False, transform_rotates_text=False, - *, parse_math=None, # defaults to rcParams['text.parse_math'] **kwargs ): From fe925f65b14aa8786896a520c7d85cb4981adbad Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 13:57:48 +0100 Subject: [PATCH 09/35] Remove get_rotation --- lib/matplotlib/text.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 24545edc2e8e..04d1dce8b52c 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -23,34 +23,6 @@ _log = logging.getLogger(__name__) -@_api.deprecated("3.6") -def get_rotation(rotation): - """ - Return *rotation* normalized to an angle between 0 and 360 degrees. - - Parameters - ---------- - rotation : float or {None, 'horizontal', 'vertical'} - Rotation angle in degrees. *None* and 'horizontal' equal 0, - 'vertical' equals 90. - - Returns - ------- - float - """ - try: - return float(rotation) % 360 - except (ValueError, TypeError) as err: - if cbook._str_equal(rotation, 'horizontal') or rotation is None: - return 0. - elif cbook._str_equal(rotation, 'vertical'): - return 90. - else: - raise ValueError(f"rotation is {rotation!r}; expected either " - "'horizontal', 'vertical', numeric value, or " - "None") from err - - def _get_textbox(text, renderer): """ Calculate the bounding box of the text. From f146c006da9856802d0911efeb10bbb35b130c04 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:01:41 +0100 Subject: [PATCH 10/35] Make all arguments to Collection and most to subclasses keyword only --- lib/matplotlib/collections.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index d951fe79dd59..a5c2e9dedf0b 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -75,8 +75,7 @@ class Collection(artist.Artist, cm.ScalarMappable): _edge_default = False @_docstring.interpd - @_api.make_keyword_only("3.6", name="edgecolors") - def __init__(self, + def __init__(self, *, edgecolors=None, facecolors=None, linewidths=None, @@ -91,7 +90,6 @@ def __init__(self, pickradius=5.0, hatch=None, urls=None, - *, zorder=1, **kwargs ): @@ -1163,8 +1161,7 @@ def legend_elements(self, prop="colors", num="auto", class PolyCollection(_CollectionWithSizes): - @_api.make_keyword_only("3.6", name="closed") - def __init__(self, verts, sizes=None, closed=True, **kwargs): + def __init__(self, verts, sizes=None, *, closed=True, **kwargs): """ Parameters ---------- @@ -1294,9 +1291,9 @@ class RegularPolyCollection(_CollectionWithSizes): _path_generator = mpath.Path.unit_regular_polygon _factor = np.pi ** (-1/2) - @_api.make_keyword_only("3.6", name="rotation") def __init__(self, numsides, + *, rotation=0, sizes=(1,), **kwargs): @@ -1560,10 +1557,10 @@ class EventCollection(LineCollection): _edge_default = True - @_api.make_keyword_only("3.6", name="lineoffset") def __init__(self, positions, # Cannot be None. orientation='horizontal', + *, lineoffset=0, linelength=1, linewidth=None, @@ -1756,8 +1753,7 @@ def __init__(self, sizes, **kwargs): class EllipseCollection(Collection): """A collection of ellipses, drawn using splines.""" - @_api.make_keyword_only("3.6", name="units") - def __init__(self, widths, heights, angles, units='points', **kwargs): + def __init__(self, widths, heights, angles, *, units='points', **kwargs): """ Parameters ---------- @@ -1844,8 +1840,7 @@ class PatchCollection(Collection): collection of patches. """ - @_api.make_keyword_only("3.6", name="match_original") - def __init__(self, patches, match_original=False, **kwargs): + def __init__(self, patches, *, match_original=False, **kwargs): """ Parameters ---------- From 20e0f800846cc1d2685d1d7626a7852a615bb1e0 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:02:50 +0100 Subject: [PATCH 11/35] Remove additional arguments to get_window_extent --- lib/matplotlib/axes/_base.py | 7 ++----- lib/matplotlib/figure.py | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 7893d7434f0d..23b1826fc9b2 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -796,12 +796,9 @@ def get_gridspec(self): """Return the `.GridSpec` associated with the subplot, or None.""" return self._subplotspec.get_gridspec() if self._subplotspec else None - @_api.delete_parameter("3.6", "args") - @_api.delete_parameter("3.6", "kwargs") - def get_window_extent(self, renderer=None, *args, **kwargs): + def get_window_extent(self, renderer=None): """ - Return the Axes bounding box in display space; *args* and *kwargs* - are empty. + Return the Axes bounding box in display space. This bounding box does not include the spines, ticks, ticklabels, or other labels. For a bounding box including these elements use diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 04b1f5dfa727..c5463a96832b 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -295,9 +295,7 @@ def contains(self, mouseevent): inside = self.bbox.contains(mouseevent.x, mouseevent.y) return inside, {} - @_api.delete_parameter("3.6", "args") - @_api.delete_parameter("3.6", "kwargs") - def get_window_extent(self, renderer=None, *args, **kwargs): + def get_window_extent(self, renderer=None): # docstring inherited return self.bbox From 9b9684dce120bbeb0eadf058d31afad0e264e7e9 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:04:09 +0100 Subject: [PATCH 12/35] Remove delay and output_args properties from ImageMagickBase --- lib/matplotlib/animation.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index b4cf9e26ab18..5db3bc93701c 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -615,18 +615,6 @@ class ImageMagickBase: _exec_key = 'animation.convert_path' _args_key = 'animation.convert_args' - @_api.deprecated("3.6") - @property - def delay(self): - return 100. / self.fps - - @_api.deprecated("3.6") - @property - def output_args(self): - extra_args = (self.extra_args if self.extra_args is not None - else mpl.rcParams[self._args_key]) - return [*extra_args, self.outfile] - def _args(self): # ImageMagick does not recognize "raw". fmt = "rgba" if self.frame_format == "raw" else self.frame_format From 350735e2713c0cf5d7faf5d50922183662a25da9 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:06:20 +0100 Subject: [PATCH 13/35] Make most arguments to Figure/figure keyword only --- lib/matplotlib/figure.py | 3 +-- lib/matplotlib/pyplot.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index c5463a96832b..563bf772830e 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -2359,10 +2359,10 @@ def __repr__(self): naxes=len(self.axes), ) - @_api.make_keyword_only("3.6", "facecolor") def __init__(self, figsize=None, dpi=None, + *, facecolor=None, edgecolor=None, linewidth=0.0, @@ -2370,7 +2370,6 @@ def __init__(self, subplotpars=None, # rc figure.subplot.* tight_layout=None, # rc figure.autolayout constrained_layout=None, # rc figure.constrained_layout.use - *, layout=None, **kwargs ): diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index f09090fc7fa7..e7a7fc192080 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -687,10 +687,10 @@ def xkcd(scale=1, length=100, randomness=2): ## Figures ## -@_api.make_keyword_only("3.6", "facecolor") def figure(num=None, # autoincrement if None, else integer from 1-N figsize=None, # defaults to rc figure.figsize dpi=None, # defaults to rc figure.dpi + *, facecolor=None, # defaults to rc figure.facecolor edgecolor=None, # defaults to rc figure.edgecolor frameon=True, From 1a907a6a5727da853c940d56e5c3fda0325077ae Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:10:04 +0100 Subject: [PATCH 14/35] Expire parameter renamings --- lib/matplotlib/collections.py | 1 - lib/matplotlib/font_manager.py | 1 - lib/matplotlib/legend_handler.py | 5 +---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index a5c2e9dedf0b..c9ae4117b9bd 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -222,7 +222,6 @@ def get_offset_transform(self): self._offset_transform._as_mpl_transform(self.axes) return self._offset_transform - @_api.rename_parameter("3.6", "transOffset", "offset_transform") def set_offset_transform(self, offset_transform): """ Set the artist offset transform. diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 5cf0533ef437..b0d3c0964408 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -1516,7 +1516,6 @@ def _cached_realpath(path): return os.path.realpath(path) -@_api.rename_parameter('3.6', "filepath", "font_filepaths") def get_font(font_filepaths, hinting_factor=None): """ Get an `.ft2font.FT2Font` object given a list of file paths. diff --git a/lib/matplotlib/legend_handler.py b/lib/matplotlib/legend_handler.py index da118ed0b978..0790150e3a9c 100644 --- a/lib/matplotlib/legend_handler.py +++ b/lib/matplotlib/legend_handler.py @@ -31,7 +31,7 @@ def legend_artist(self, legend, orig_handle, fontsize, handlebox) import numpy as np -from matplotlib import _api, cbook +from matplotlib import cbook from matplotlib.lines import Line2D from matplotlib.patches import Rectangle import matplotlib.collections as mcoll @@ -471,7 +471,6 @@ def update_prop(self, legend_handle, orig_handle, legend): legend_handle.set_clip_box(None) legend_handle.set_clip_path(None) - @_api.rename_parameter("3.6", "transOffset", "offset_transform") def create_collection(self, orig_handle, sizes, offsets, offset_transform): return type(orig_handle)( orig_handle.get_numsides(), @@ -504,7 +503,6 @@ def create_artists(self, legend, orig_handle, class HandlerPathCollection(HandlerRegularPolyCollection): r"""Handler for `.PathCollection`\s, which are used by `~.Axes.scatter`.""" - @_api.rename_parameter("3.6", "transOffset", "offset_transform") def create_collection(self, orig_handle, sizes, offsets, offset_transform): return type(orig_handle)( [orig_handle.get_paths()[0]], sizes=sizes, @@ -515,7 +513,6 @@ def create_collection(self, orig_handle, sizes, offsets, offset_transform): class HandlerCircleCollection(HandlerRegularPolyCollection): r"""Handler for `.CircleCollection`\s.""" - @_api.rename_parameter("3.6", "transOffset", "offset_transform") def create_collection(self, orig_handle, sizes, offsets, offset_transform): return type(orig_handle)( sizes, offsets=offsets, offset_transform=offset_transform) From 9044761a502509faffe2e4078d48265feb1e457b Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:13:05 +0100 Subject: [PATCH 15/35] Make most arguments to Image classes keyword only --- lib/matplotlib/image.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index bc3e35bb7d2c..cb5129aa6fc8 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -901,8 +901,8 @@ class AxesImage(_ImageBase): **kwargs : `.Artist` properties """ - @_api.make_keyword_only("3.6", name="cmap") def __init__(self, ax, + *, cmap=None, norm=None, interpolation=None, @@ -911,7 +911,6 @@ def __init__(self, ax, filternorm=True, filterrad=4.0, resample=False, - *, interpolation_stage=None, **kwargs ): @@ -1208,11 +1207,11 @@ class PcolorImage(AxesImage): and it is used by pcolorfast for the corresponding grid type. """ - @_api.make_keyword_only("3.6", name="cmap") def __init__(self, ax, x=None, y=None, A=None, + *, cmap=None, norm=None, **kwargs @@ -1360,8 +1359,8 @@ class FigureImage(_ImageBase): _interpolation = 'nearest' - @_api.make_keyword_only("3.6", name="cmap") def __init__(self, fig, + *, cmap=None, norm=None, offsetx=0, @@ -1419,8 +1418,8 @@ def set_data(self, A): class BboxImage(_ImageBase): """The Image class whose size is determined by the given bbox.""" - @_api.make_keyword_only("3.6", name="cmap") def __init__(self, bbox, + *, cmap=None, norm=None, interpolation=None, From a8fd351611d7c9d43a005ad9cbe393fc43ef1ef0 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:14:20 +0100 Subject: [PATCH 16/35] Make most arguments to Legend keyword only --- lib/matplotlib/legend.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index c25b519fdb03..315cc0be7aea 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -342,10 +342,10 @@ class Legend(Artist): def __str__(self): return "Legend" - @_api.make_keyword_only("3.6", "loc") @_docstring.dedent_interpd def __init__( self, parent, handles, labels, + *, loc=None, numpoints=None, # number of points in the legend line markerscale=None, # relative size of legend markers vs. original @@ -383,7 +383,6 @@ def __init__( handler_map=None, title_fontproperties=None, # properties for the legend title alignment="center", # control the alignment within the legend box - *, ncol=1, # synonym for ncols (backward compatibility) draggable=False # whether the legend can be dragged with the mouse ): From 61fa4f2baa2335ae8b677a6250e6bd467a69a713 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:16:23 +0100 Subject: [PATCH 17/35] Make most arguments to OffsetBox classes keyword only --- lib/matplotlib/offsetbox.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index a46b9cd4319d..64b2c7720664 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -533,8 +533,7 @@ class PaddedBox(OffsetBox): it when rendering. """ - @_api.make_keyword_only("3.6", name="draw_frame") - def __init__(self, child, pad=0., draw_frame=False, patch_attrs=None): + def __init__(self, child, pad=0., *, draw_frame=False, patch_attrs=None): """ Parameters ---------- @@ -715,8 +714,8 @@ class TextArea(OffsetBox): child text. """ - @_api.make_keyword_only("3.6", name="textprops") def __init__(self, s, + *, textprops=None, multilinebaseline=False, ): @@ -929,8 +928,7 @@ class AnchoredOffsetbox(OffsetBox): 'center': 10, } - @_api.make_keyword_only("3.6", name="pad") - def __init__(self, loc, + def __init__(self, loc, *, pad=0.4, borderpad=0.5, child=None, prop=None, frameon=True, bbox_to_anchor=None, @@ -1103,8 +1101,7 @@ class AnchoredText(AnchoredOffsetbox): AnchoredOffsetbox with Text. """ - @_api.make_keyword_only("3.6", name="pad") - def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs): + def __init__(self, s, loc, *, pad=0.4, borderpad=0.5, prop=None, **kwargs): """ Parameters ---------- @@ -1144,8 +1141,7 @@ def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs): class OffsetImage(OffsetBox): - @_api.make_keyword_only("3.6", name="zoom") - def __init__(self, arr, + def __init__(self, arr, *, zoom=1, cmap=None, norm=None, @@ -1229,8 +1225,7 @@ def __str__(self): return f"AnnotationBbox({self.xy[0]:g},{self.xy[1]:g})" @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="xycoords") - def __init__(self, offsetbox, xy, + def __init__(self, offsetbox, xy, *, xybox=None, xycoords='data', boxcoords=None, From f7576ff43c20f0b288f19d1605c6e7ea20078879 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:24:55 +0100 Subject: [PATCH 18/35] Make most arguments to Cell keyword only --- lib/matplotlib/table.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/matplotlib/table.py b/lib/matplotlib/table.py index 2fb6df83ffe1..f8eb7ede5456 100644 --- a/lib/matplotlib/table.py +++ b/lib/matplotlib/table.py @@ -51,14 +51,12 @@ class Cell(Rectangle): 'vertical': 'RL' } - @_api.make_keyword_only("3.6", name="edgecolor") - def __init__(self, xy, width, height, + def __init__(self, xy, width, height, *, edgecolor='k', facecolor='w', fill=True, text='', loc=None, fontproperties=None, - *, visible_edges='closed', ): """ From f86cfb24084dc72c931f3b11c01f8473016f5d04 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:28:43 +0100 Subject: [PATCH 19/35] Remove get_texmanager --- lib/matplotlib/textpath.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py index 656124216594..945624a2d7a2 100644 --- a/lib/matplotlib/textpath.py +++ b/lib/matplotlib/textpath.py @@ -4,7 +4,7 @@ import numpy as np -from matplotlib import _api, _text_helpers, dviread +from matplotlib import _text_helpers, dviread from matplotlib.font_manager import ( FontProperties, get_font, fontManager as _fontManager ) @@ -211,13 +211,6 @@ def get_glyphs_mathtext(self, prop, s, glyph_map=None, return (list(zip(glyph_ids, xpositions, ypositions, sizes)), glyph_map_new, myrects) - @_api.deprecated("3.6", alternative="TexManager()") - def get_texmanager(self): - """Return the cached `~.texmanager.TexManager` instance.""" - if self._texmanager is None: - self._texmanager = TexManager() - return self._texmanager - def get_glyphs_tex(self, prop, s, glyph_map=None, return_new_glyphs_only=False): """Convert the string *s* to vertices and codes using usetex mode.""" From 6cdd1bb03b2757810159aec15139bcabef7e58c9 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:29:25 +0100 Subject: [PATCH 20/35] Remove identify --- lib/matplotlib/transforms.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index a31e58da8dd7..6b666234fc17 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -1949,17 +1949,6 @@ def set(self, other): self._mtx = other.get_matrix() self.invalidate() - @staticmethod - @_api.deprecated("3.6", alternative="Affine2D()") - def identity(): - """ - Return a new `Affine2D` object that is the identity transform. - - Unless this transform will be mutated later on, consider using - the faster `IdentityTransform` class instead. - """ - return Affine2D() - def clear(self): """ Reset the underlying matrix to the identity transform. From c9942bebb917e02231294d7dfffa8f082deb68e6 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:46:28 +0100 Subject: [PATCH 21/35] Remove move_from_center. tick_update_position, set_pane_pos, and w_*axis --- lib/mpl_toolkits/mplot3d/axes3d.py | 7 ------- lib/mpl_toolkits/mplot3d/axis3d.py | 20 -------------------- 2 files changed, 27 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 67f438f107dd..3a27315cfe71 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -219,13 +219,6 @@ def get_zaxis(self): get_zgridlines = _axis_method_wrapper("zaxis", "get_gridlines") get_zticklines = _axis_method_wrapper("zaxis", "get_ticklines") - w_xaxis = _api.deprecated("3.1", alternative="xaxis", removal="3.8")( - property(lambda self: self.xaxis)) - w_yaxis = _api.deprecated("3.1", alternative="yaxis", removal="3.8")( - property(lambda self: self.yaxis)) - w_zaxis = _api.deprecated("3.1", alternative="zaxis", removal="3.8")( - property(lambda self: self.zaxis)) - @_api.deprecated("3.7") def unit_cube(self, vals=None): return self._unit_cube(vals) diff --git a/lib/mpl_toolkits/mplot3d/axis3d.py b/lib/mpl_toolkits/mplot3d/axis3d.py index d6d50fd953b9..729b98b1a4c5 100644 --- a/lib/mpl_toolkits/mplot3d/axis3d.py +++ b/lib/mpl_toolkits/mplot3d/axis3d.py @@ -13,15 +13,6 @@ from . import art3d, proj3d -@_api.deprecated("3.6", alternative="a vendored copy of _move_from_center") -def move_from_center(coord, centers, deltas, axmask=(True, True, True)): - """ - For each coordinate where *axmask* is True, move *coord* away from - *centers* by *deltas*. - """ - return _move_from_center(coord, centers, deltas, axmask=axmask) - - def _move_from_center(coord, centers, deltas, axmask=(True, True, True)): """ For each coordinate where *axmask* is True, move *coord* away from @@ -31,12 +22,6 @@ def _move_from_center(coord, centers, deltas, axmask=(True, True, True)): return coord + axmask * np.copysign(1, coord - centers) * deltas -@_api.deprecated("3.6", alternative="a vendored copy of _tick_update_position") -def tick_update_position(tick, tickxs, tickys, labelpos): - """Update tick line and label position and style.""" - _tick_update_position(tick, tickxs, tickys, labelpos) - - def _tick_update_position(tick, tickxs, tickys, labelpos): """Update tick line and label position and style.""" @@ -198,11 +183,6 @@ def get_minor_ticks(self, numticks=None): obj.set_transform(self.axes.transData) return ticks - @_api.deprecated("3.6") - def set_pane_pos(self, xys): - """Set pane position.""" - self._set_pane_pos(xys) - def _set_pane_pos(self, xys): xys = np.asarray(xys) xys = xys[:, :2] From ba959ad756ca40b2ea41fd32e14dd886d6c55772 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:48:11 +0100 Subject: [PATCH 22/35] Remove AddList, Padded, SizeFromFunc, and GetExtentHelper --- lib/mpl_toolkits/axes_grid1/axes_size.py | 67 ------------------------ 1 file changed, 67 deletions(-) diff --git a/lib/mpl_toolkits/axes_grid1/axes_size.py b/lib/mpl_toolkits/axes_grid1/axes_size.py index e3de8ab60a3f..3b47dbce9702 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_size.py +++ b/lib/mpl_toolkits/axes_grid1/axes_size.py @@ -37,18 +37,6 @@ def get_size(self, renderer): return a_rel_size + b_rel_size, a_abs_size + b_abs_size -@_api.deprecated( - "3.6", alternative="sum(sizes, start=Fixed(0))") -class AddList(_Base): - def __init__(self, add_list): - self._list = add_list - - def get_size(self, renderer): - sum_rel_size = sum([a.get_size(renderer)[0] for a in self._list]) - sum_abs_size = sum([a.get_size(renderer)[1] for a in self._list]) - return sum_rel_size, sum_abs_size - - class Fixed(_Base): """ Simple fixed size with absolute part = *fixed_size* and relative part = 0. @@ -204,24 +192,6 @@ def get_size(self, renderer): return rel_size, abs_size -@_api.deprecated("3.6", alternative="size + pad") -class Padded(_Base): - """ - Return an instance where the absolute part of *size* is - increase by the amount of *pad*. - """ - - def __init__(self, size, pad): - self._size = size - self._pad = pad - - def get_size(self, renderer): - r, a = self._size.get_size(renderer) - rel_size = r - abs_size = a + self._pad - return rel_size, abs_size - - def from_any(size, fraction_ref=None): """ Create a Fixed unit when the first argument is a float, or a @@ -239,43 +209,6 @@ def from_any(size, fraction_ref=None): raise ValueError("Unknown format") -@_api.deprecated("3.6") -class SizeFromFunc(_Base): - def __init__(self, func): - self._func = func - - def get_size(self, renderer): - rel_size = 0. - - bb = self._func(renderer) - dpi = renderer.points_to_pixels(72.) - abs_size = bb/dpi - - return rel_size, abs_size - - -@_api.deprecated("3.6") -class GetExtentHelper: - _get_func_map = { - "left": lambda self, axes_bbox: axes_bbox.xmin - self.xmin, - "right": lambda self, axes_bbox: self.xmax - axes_bbox.xmax, - "bottom": lambda self, axes_bbox: axes_bbox.ymin - self.ymin, - "top": lambda self, axes_bbox: self.ymax - axes_bbox.ymax, - } - - def __init__(self, ax, direction): - _api.check_in_list(self._get_func_map, direction=direction) - self._ax_list = [ax] if isinstance(ax, Axes) else ax - self._direction = direction - - def __call__(self, renderer): - get_func = self._get_func_map[self._direction] - vl = [get_func(ax.get_tightbbox(renderer, call_axes_locator=False), - ax.bbox) - for ax in self._ax_list] - return max(vl) - - class _AxesDecorationsSize(_Base): """ Fixed size, corresponding to the size of decorations on a given Axes side. From 54a11c075961a4e58da8a7c25cb5aa691defda50 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:49:35 +0100 Subject: [PATCH 23/35] Remove delta* and new_gridlines --- lib/mpl_toolkits/axisartist/axislines.py | 43 ------------------------ 1 file changed, 43 deletions(-) diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index 06613b0cc8d6..9752a85139b3 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -90,11 +90,6 @@ class _Base: def update_lim(self, axes): pass - delta1 = _api.deprecated("3.6")( - property(lambda self: 0.00001, lambda self, value: None)) - delta2 = _api.deprecated("3.6")( - property(lambda self: 0.00001, lambda self, value: None)) - def _to_xy(self, values, const): """ Create a (*values.shape, 2)-shape array representing (x, y) pairs. @@ -323,29 +318,6 @@ def get_gridlines(self, which, axis): """ return [] - @_api.deprecated("3.6") - def new_gridlines(self, ax): - """ - Create and return a new GridlineCollection instance. - - *which* : "major" or "minor" - *axis* : "both", "x" or "y" - - """ - gridlines = GridlinesCollection( - None, transform=ax.transData, colors=mpl.rcParams['grid.color'], - linestyles=mpl.rcParams['grid.linestyle'], - linewidths=mpl.rcParams['grid.linewidth']) - ax._set_artist_props(gridlines) - gridlines.set_grid_helper(self) - - ax.axes._set_artist_props(gridlines) - # gridlines.set_clip_path(self.axes.patch) - # set_clip_path need to be deferred after Axes.cla is completed. - # It is done inside the cla. - - return gridlines - class GridHelperRectlinear(GridHelperBase): @@ -455,21 +427,6 @@ def toggle_axisline(self, b=None): def axis(self): return self._axislines - @_api.deprecated("3.6") - def new_gridlines(self, grid_helper=None): - """ - Create and return a new GridlineCollection instance. - - *which* : "major" or "minor" - *axis* : "both", "x" or "y" - - """ - if grid_helper is None: - grid_helper = self.get_grid_helper() - - gridlines = grid_helper.new_gridlines(self) - return gridlines - def clear(self): # docstring inherited From 55963294701bbcd38b36302c5aaedd88d0c94b61 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 14:50:49 +0100 Subject: [PATCH 24/35] Remove dist and make most argument to set_zlim keyword only --- lib/mpl_toolkits/mplot3d/axes3d.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 3a27315cfe71..9934fb025216 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -57,7 +57,6 @@ class Axes3D(Axes): _axis_names = ("x", "y", "z") Axes._shared_axes["z"] = cbook.Grouper() - dist = _api.deprecate_privatize_attribute("3.6") vvec = _api.deprecate_privatize_attribute("3.7") eye = _api.deprecate_privatize_attribute("3.7") sx = _api.deprecate_privatize_attribute("3.7") @@ -676,9 +675,8 @@ def get_w_lims(self): return minx, maxx, miny, maxy, minz, maxz # set_xlim, set_ylim are directly inherited from base Axes. - @_api.make_keyword_only("3.6", "emit") - def set_zlim(self, bottom=None, top=None, emit=True, auto=False, - *, zmin=None, zmax=None): + def set_zlim(self, bottom=None, top=None, *, emit=True, auto=False, + zmin=None, zmax=None): """ Set 3D z limits. From 98866a2d988e500d4b1b5818ab5e090beea5859b Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 15:01:08 +0100 Subject: [PATCH 25/35] Make most argument to set_*lim keyword only --- lib/matplotlib/axes/_base.py | 10 ++++------ lib/matplotlib/projections/polar.py | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 23b1826fc9b2..0220d04aa356 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -3565,9 +3565,8 @@ def _validate_converted_limits(self, limit, convert): raise ValueError("Axis limits cannot be NaN or Inf") return converted_limit - @_api.make_keyword_only("3.6", "emit") - def set_xlim(self, left=None, right=None, emit=True, auto=False, - *, xmin=None, xmax=None): + def set_xlim(self, left=None, right=None, *, emit=True, auto=False, + xmin=None, xmax=None): """ Set the x-axis view limits. @@ -3797,9 +3796,8 @@ def get_ylim(self): """ return tuple(self.viewLim.intervaly) - @_api.make_keyword_only("3.6", "emit") - def set_ylim(self, bottom=None, top=None, emit=True, auto=False, - *, ymin=None, ymax=None): + def set_ylim(self, bottom=None, top=None, *, emit=True, auto=False, + ymin=None, ymax=None): """ Set the y-axis view limits. diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index 7e85e1626844..9ac9bbe73ce9 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -1228,8 +1228,8 @@ def get_rorigin(self): def get_rsign(self): return np.sign(self._originViewLim.y1 - self._originViewLim.y0) - @_api.make_keyword_only("3.6", "emit") - def set_rlim(self, bottom=None, top=None, emit=True, auto=False, **kwargs): + def set_rlim(self, bottom=None, top=None, *, + emit=True, auto=False, **kwargs): """ Set the radial axis view limits. From 1b2c01182d6a4fc8963edee03f4649cfb88ed86c Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 15:02:00 +0100 Subject: [PATCH 26/35] Remove label --- lib/matplotlib/axis.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 31ad88595f0b..c1ceff1ff409 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -188,11 +188,6 @@ def __init__( self.update_position(loc) - @property - @_api.deprecated("3.1", alternative="Tick.label1", removal="3.8") - def label(self): - return self.label1 - def _set_labelrotation(self, labelrotation): if isinstance(labelrotation, str): mode = labelrotation From 74cb2886404823fe4ff3d01227f13d614934ca79 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 15:04:13 +0100 Subject: [PATCH 27/35] Remove execute_constrained_layout --- lib/matplotlib/figure.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 563bf772830e..d2568fddbf06 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -3474,21 +3474,6 @@ def handler(ev): return None if event is None else event.name == "key_press_event" - @_api.deprecated("3.6", alternative="figure.get_layout_engine().execute()") - def execute_constrained_layout(self, renderer=None): - """ - Use ``layoutgrid`` to determine pos positions within Axes. - - See also `.set_constrained_layout_pads`. - - Returns - ------- - layoutgrid : private debugging object - """ - if not isinstance(self.get_layout_engine(), ConstrainedLayoutEngine): - return None - return self.get_layout_engine().execute(self) - def tight_layout(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None): """ Adjust the padding between and around subplots. From 7c7a34abacd67209d87da63fba334857265273c5 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 15:06:06 +0100 Subject: [PATCH 28/35] Remove CleanupTestCase, cleanup, and check_freetype_version --- lib/matplotlib/testing/decorators.py | 66 +--------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index 3240939c96d4..d2203729b763 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -6,7 +6,6 @@ import shutil import string import sys -import unittest import warnings from packaging.version import parse as parse_version @@ -14,8 +13,7 @@ import matplotlib.style import matplotlib.units import matplotlib.testing -from matplotlib import (_api, _pylab_helpers, cbook, ft2font, pyplot as plt, - ticker) +from matplotlib import _pylab_helpers, cbook, ft2font, pyplot as plt, ticker from .compare import comparable_formats, compare_images, make_test_filename from .exceptions import ImageComparisonFailure @@ -32,68 +30,6 @@ def _cleanup_cm(): plt.close("all") -@_api.deprecated("3.6", alternative="a vendored copy of the existing code, " - "including the private function _cleanup_cm") -class CleanupTestCase(unittest.TestCase): - """A wrapper for unittest.TestCase that includes cleanup operations.""" - @classmethod - def setUpClass(cls): - cls._cm = _cleanup_cm().__enter__() - - @classmethod - def tearDownClass(cls): - cls._cm.__exit__(None, None, None) - - -@_api.deprecated("3.6", alternative="a vendored copy of the existing code, " - "including the private function _cleanup_cm") -def cleanup(style=None): - """ - A decorator to ensure that any global state is reset before - running a test. - - Parameters - ---------- - style : str, dict, or list, optional - The style(s) to apply. Defaults to ``["classic", - "_classic_test_patch"]``. - """ - - # If cleanup is used without arguments, *style* will be a callable, and we - # pass it directly to the wrapper generator. If cleanup if called with an - # argument, it is a string naming a style, and the function will be passed - # as an argument to what we return. This is a confusing, but somewhat - # standard, pattern for writing a decorator with optional arguments. - - def make_cleanup(func): - if inspect.isgeneratorfunction(func): - @functools.wraps(func) - def wrapped_callable(*args, **kwargs): - with _cleanup_cm(), matplotlib.style.context(style): - yield from func(*args, **kwargs) - else: - @functools.wraps(func) - def wrapped_callable(*args, **kwargs): - with _cleanup_cm(), matplotlib.style.context(style): - func(*args, **kwargs) - - return wrapped_callable - - if callable(style): - result = make_cleanup(style) - # Default of mpl_test_settings fixture and image_comparison too. - style = ["classic", "_classic_test_patch"] - return result - else: - return make_cleanup - - -@_api.deprecated("3.6", alternative="a vendored copy of the existing code " - "of _check_freetype_version") -def check_freetype_version(ver): - return _check_freetype_version(ver) - - def _check_freetype_version(ver): if ver is None: return True From a5d18ab1e3b4d414770fc462cca188717c533450 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 15:13:11 +0100 Subject: [PATCH 29/35] Remove use_line_collection argument to stem --- lib/matplotlib/axes/_axes.py | 42 +++++++------------------------ lib/matplotlib/pyplot.py | 8 ++---- lib/matplotlib/tests/test_axes.py | 31 ++++++----------------- 3 files changed, 18 insertions(+), 63 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 5354d8fd79f2..1e9e167a7a08 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2886,9 +2886,8 @@ def broken_barh(self, xranges, yrange, **kwargs): return col @_preprocess_data() - @_api.delete_parameter("3.6", "use_line_collection") def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, - label=None, use_line_collection=True, orientation='vertical'): + label=None, orientation='vertical'): """ Create a stem plot. @@ -2932,8 +2931,8 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, cycle. Note: Markers specified through this parameter (e.g. 'x') will be - silently ignored (unless using ``use_line_collection=False``). - Instead, markers should be specified using *markerfmt*. + silently ignored. Instead, markers should be specified using + *markerfmt*. markerfmt : str, optional A string defining the color and/or shape of the markers at the stem @@ -2953,14 +2952,6 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, label : str, default: None The label to use for the stems in legends. - use_line_collection : bool, default: True - *Deprecated since 3.6* - - If ``True``, store and plot the stem lines as a - `~.collections.LineCollection` instead of individual lines, which - significantly increases performance. If ``False``, defaults to the - old behavior of using a list of `.Line2D` objects. - data : indexable object, optional DATA_PARAMETER_PLACEHOLDER @@ -3024,27 +3015,12 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, basestyle, basemarker, basecolor = _process_plot_format(basefmt) # New behaviour in 3.1 is to use a LineCollection for the stemlines - if use_line_collection: - if linestyle is None: - linestyle = mpl.rcParams['lines.linestyle'] - xlines = self.vlines if orientation == "vertical" else self.hlines - stemlines = xlines( - locs, bottom, heads, - colors=linecolor, linestyles=linestyle, label="_nolegend_") - # Old behaviour is to plot each of the lines individually - else: - stemlines = [] - for loc, head in zip(locs, heads): - if orientation == 'horizontal': - xs = [bottom, head] - ys = [loc, loc] - else: - xs = [loc, loc] - ys = [bottom, head] - l, = self.plot(xs, ys, - color=linecolor, linestyle=linestyle, - marker=linemarker, label="_nolegend_") - stemlines.append(l) + if linestyle is None: + linestyle = mpl.rcParams['lines.linestyle'] + xlines = self.vlines if orientation == "vertical" else self.hlines + stemlines = xlines( + locs, bottom, heads, + colors=linecolor, linestyles=linestyle, label="_nolegend_") if orientation == 'horizontal': marker_x = heads diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index e7a7fc192080..5a71207a2af7 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2922,14 +2922,10 @@ def stackplot( @_copy_docstring_and_deprecators(Axes.stem) def stem( *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, - label=None, - use_line_collection=_api.deprecation._deprecated_parameter, - orientation='vertical', data=None): + label=None, orientation='vertical', data=None): return gca().stem( *args, linefmt=linefmt, markerfmt=markerfmt, basefmt=basefmt, - bottom=bottom, label=label, - use_line_collection=use_line_collection, - orientation=orientation, + bottom=bottom, label=label, orientation=orientation, **({"data": data} if data is not None else {})) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index c8e1f53465f2..bd26419dee4d 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4047,23 +4047,15 @@ def test_hist_stacked_weighted(): ax.hist((d1, d2), weights=(w1, w2), histtype="stepfilled", stacked=True) -@pytest.mark.parametrize("use_line_collection", [True, False], - ids=['w/ line collection', 'w/o line collection']) @image_comparison(['stem.png'], style='mpl20', remove_text=True) -def test_stem(use_line_collection): +def test_stem(): x = np.linspace(0.1, 2 * np.pi, 100) fig, ax = plt.subplots() # Label is a single space to force a legend to be drawn, but to avoid any # text being drawn - if use_line_collection: - ax.stem(x, np.cos(x), - linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ') - else: - with pytest.warns(MatplotlibDeprecationWarning, match='deprecated'): - ax.stem(x, np.cos(x), - linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ', - use_line_collection=False) + ax.stem(x, np.cos(x), + linefmt='C2-.', markerfmt='k+', basefmt='C1-.', label=' ') ax.legend() @@ -4162,23 +4154,14 @@ def test_stem_dates(): ax.stem(xs, ys) -@pytest.mark.parametrize("use_line_collection", [True, False], - ids=['w/ line collection', 'w/o line collection']) @image_comparison(['stem_orientation.png'], style='mpl20', remove_text=True) -def test_stem_orientation(use_line_collection): +def test_stem_orientation(): x = np.linspace(0.1, 2*np.pi, 50) fig, ax = plt.subplots() - if use_line_collection: - ax.stem(x, np.cos(x), - linefmt='C2-.', markerfmt='kx', basefmt='C1-.', - orientation='horizontal') - else: - with pytest.warns(MatplotlibDeprecationWarning, match='deprecated'): - ax.stem(x, np.cos(x), - linefmt='C2-.', markerfmt='kx', basefmt='C1-.', - use_line_collection=False, - orientation='horizontal') + ax.stem(x, np.cos(x), + linefmt='C2-.', markerfmt='kx', basefmt='C1-.', + orientation='horizontal') @image_comparison(['hist_stacked_stepfilled_alpha']) From 759f3f79e43f7ef613e67b3a681ee455292dca96 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 15:17:04 +0100 Subject: [PATCH 30/35] Remove get_renderer_cache --- lib/matplotlib/axes/_base.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 0220d04aa356..05ee45a8f4f1 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -3078,10 +3078,6 @@ def redraw_in_frame(self): stack.enter_context(artist._cm_set(visible=False)) self.draw(self.figure.canvas.get_renderer()) - @_api.deprecated("3.6", alternative="Axes.figure.canvas.get_renderer()") - def get_renderer_cache(self): - return self.figure.canvas.get_renderer() - # Axes rectangle characteristics def get_frame_on(self): From d0901659e451236070a40b6ea9a83ef562d9b259 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 15:26:25 +0100 Subject: [PATCH 31/35] Remove privatized or unused helper functions --- lib/matplotlib/backends/backend_pdf.py | 26 ----------------- lib/matplotlib/backends/backend_pgf.py | 39 +------------------------- lib/matplotlib/backends/backend_ps.py | 22 --------------- lib/matplotlib/backends/backend_svg.py | 32 +-------------------- 4 files changed, 2 insertions(+), 117 deletions(-) diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index 053b36d90112..1152db67b373 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -92,11 +92,6 @@ # * draw_quad_mesh -@_api.deprecated("3.6", alternative="a vendored copy of _fill") -def fill(strings, linelen=75): - return _fill(strings, linelen=linelen) - - def _fill(strings, linelen=75): """ Make one string from sequence of strings, with whitespace in between. @@ -442,29 +437,10 @@ def __lt__(self, other): def __hash__(self): return hash(self.name) - @staticmethod - @_api.deprecated("3.6") - def hexify(match): - return '#%02x' % ord(match.group()) - def pdfRepr(self): return b'/' + self.name -@_api.deprecated("3.6") -class Operator: - __slots__ = ('op',) - - def __init__(self, op): - self.op = op - - def __repr__(self): - return '' % self.op - - def pdfRepr(self): - return self.op - - class Verbatim: """Store verbatim PDF command content for later inclusion in the stream.""" def __init__(self, x): @@ -515,8 +491,6 @@ class Op(Enum): clip = b'W' shading = b'sh' - op = _api.deprecated('3.6')(property(lambda self: self.value)) - def pdfRepr(self): return self.value diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index 2cca0864c239..088292e8810e 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -14,7 +14,7 @@ from PIL import Image import matplotlib as mpl -from matplotlib import _api, cbook, font_manager as fm +from matplotlib import cbook, font_manager as fm from matplotlib.backend_bases import ( _Backend, FigureCanvasBase, FigureManagerBase, RendererBase ) @@ -32,28 +32,6 @@ # %f/{:f} format rather than %s/{} to avoid triggering scientific notation, # which is not recognized by TeX. - -@_api.caching_module_getattr -class __getattr__: - NO_ESCAPE = _api.deprecated("3.6", obj_type="")( - property(lambda self: r"(? Date: Sat, 14 Jan 2023 15:35:01 +0100 Subject: [PATCH 32/35] Make most arguments to Patch classes keyword only --- lib/matplotlib/patches.py | 53 +++++++++++++++------------------------ 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index e60a14f592fb..feeb6b597b25 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -45,8 +45,7 @@ class Patch(artist.Artist): # subclass-by-subclass basis. _edge_default = False - @_api.make_keyword_only("3.6", name="edgecolor") - def __init__(self, + def __init__(self, *, edgecolor=None, facecolor=None, color=None, @@ -687,9 +686,8 @@ def __str__(self): return fmt % pars @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="angle") - def __init__(self, xy, width, height, angle=0.0, *, - rotation_point='xy', **kwargs): + def __init__(self, xy, width, height, *, + angle=0.0, rotation_point='xy', **kwargs): """ Parameters ---------- @@ -890,9 +888,8 @@ def __str__(self): self.orientation) @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="radius") - def __init__(self, xy, numVertices, radius=5, orientation=0, - **kwargs): + def __init__(self, xy, numVertices, *, + radius=5, orientation=0, **kwargs): """ Parameters ---------- @@ -1078,8 +1075,7 @@ def __str__(self): return "Polygon0()" @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="closed") - def __init__(self, xy, closed=True, **kwargs): + def __init__(self, xy, *, closed=True, **kwargs): """ Parameters ---------- @@ -1177,8 +1173,7 @@ def __str__(self): return fmt % pars @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="width") - def __init__(self, center, r, theta1, theta2, width=None, **kwargs): + def __init__(self, center, r, theta1, theta2, *, width=None, **kwargs): """ A wedge centered at *x*, *y* center with radius *r* that sweeps *theta1* to *theta2* (in degrees). If *width* is given, @@ -1266,8 +1261,7 @@ def __str__(self): [0.8, 0.3], [0.8, 0.1]]) @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="width") - def __init__(self, x, y, dx, dy, width=1.0, **kwargs): + def __init__(self, x, y, dx, dy, *, width=1.0, **kwargs): """ Draws an arrow from (*x*, *y*) to (*x* + *dx*, *y* + *dy*). The width of the arrow is scaled by *width*. @@ -1322,9 +1316,9 @@ def __str__(self): return "FancyArrow()" @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="width") - def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, - head_width=None, head_length=None, shape='full', overhang=0, + def __init__(self, x, y, dx, dy, *, + width=0.001, length_includes_head=False, head_width=None, + head_length=None, shape='full', overhang=0, head_starts_at_zero=False, **kwargs): """ Parameters @@ -1493,8 +1487,7 @@ def __str__(self): return s % (self.xy[0], self.xy[1], self.radius, self.numvertices) @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="resolution") - def __init__(self, xy, radius=5, + def __init__(self, xy, radius=5, *, resolution=20, # the number of vertices ** kwargs): """ @@ -1521,8 +1514,7 @@ def __str__(self): return fmt % pars @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="angle") - def __init__(self, xy, width, height, angle=0, **kwargs): + def __init__(self, xy, width, height, *, angle=0, **kwargs): """ Parameters ---------- @@ -1908,9 +1900,8 @@ def __str__(self): return fmt % pars @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="angle") - def __init__(self, xy, width, height, angle=0.0, - theta1=0.0, theta2=360.0, **kwargs): + def __init__(self, xy, width, height, *, + angle=0.0, theta1=0.0, theta2=360.0, **kwargs): """ Parameters ---------- @@ -4043,13 +4034,10 @@ def __str__(self): return f"{type(self).__name__}({self._path_original})" @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="path") - def __init__(self, posA=None, posB=None, path=None, - arrowstyle="simple", connectionstyle="arc3", - patchA=None, patchB=None, - shrinkA=2, shrinkB=2, - mutation_scale=1, mutation_aspect=1, - **kwargs): + def __init__(self, posA=None, posB=None, *, + path=None, arrowstyle="simple", connectionstyle="arc3", + patchA=None, patchB=None, shrinkA=2, shrinkB=2, + mutation_scale=1, mutation_aspect=1, **kwargs): """ There are two ways for defining an arrow: @@ -4372,8 +4360,7 @@ def __str__(self): (self.xy1[0], self.xy1[1], self.xy2[0], self.xy2[1]) @_docstring.dedent_interpd - @_api.make_keyword_only("3.6", name="axesA") - def __init__(self, xyA, xyB, coordsA, coordsB=None, + def __init__(self, xyA, xyB, coordsA, coordsB=None, *, axesA=None, axesB=None, arrowstyle="-", connectionstyle="arc3", From 832924b1699035dbd94c2f859440d9a7b77c856c Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 Jan 2023 18:19:12 +0100 Subject: [PATCH 33/35] Fix documentation --- doc/api/axes_api.rst | 1 - doc/api/axis_api.rst | 4 ---- doc/api/prev_api_changes/api_changes_3.1.0.rst | 8 ++++---- doc/api/prev_api_changes/api_changes_3.6.0/removals.rst | 2 +- doc/api/toolkits/mplot3d/axes3d.rst | 3 --- doc/users/prev_whats_new/dflt_style_changes.rst | 2 +- doc/users/prev_whats_new/whats_new_1.4.rst | 2 +- lib/matplotlib/mlab.py | 3 --- 8 files changed, 7 insertions(+), 18 deletions(-) diff --git a/doc/api/axes_api.rst b/doc/api/axes_api.rst index 8d0951626f72..07586690347f 100644 --- a/doc/api/axes_api.rst +++ b/doc/api/axes_api.rst @@ -556,7 +556,6 @@ Drawing Axes.draw Axes.draw_artist Axes.redraw_in_frame - Axes.get_renderer_cache Axes.get_rasterization_zorder Axes.set_rasterization_zorder diff --git a/doc/api/axis_api.rst b/doc/api/axis_api.rst index e7da26a11706..a177f82a4a9a 100644 --- a/doc/api/axis_api.rst +++ b/doc/api/axis_api.rst @@ -138,7 +138,6 @@ Rendering helpers Axis.get_minpos Axis.get_tick_space - Axis.get_ticklabel_extents Axis.get_tightbbox @@ -179,7 +178,6 @@ XAxis Specific :nosignatures: XAxis.axis_name - XAxis.get_text_heights XAxis.get_ticks_position XAxis.set_ticks_position XAxis.set_label_position @@ -195,7 +193,6 @@ YAxis Specific :nosignatures: YAxis.axis_name - YAxis.get_text_widths YAxis.get_ticks_position YAxis.set_offset_position YAxis.set_ticks_position @@ -260,7 +257,6 @@ specify a matching series of labels. Calling ``set_ticks`` makes a Tick.get_loc Tick.get_pad - Tick.get_pad_pixels Tick.get_tick_padding Tick.get_tickdir Tick.get_view_interval 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 3e67af8f64cf..18f25d459200 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 @@ -463,7 +463,7 @@ instead of ``\usepackage{ucs}\usepackage[utf8x]{inputenc}``. Exception changes ----------------- -- `mpl_toolkits.axes_grid1.axes_size.GetExtentHelper` now raises `ValueError` +- ``mpl_toolkits.axes_grid1.axes_size.GetExtentHelper`` now raises `ValueError` for invalid directions instead of `KeyError`. - Previously, subprocess failures in the animation framework would raise either in a `RuntimeError` or a `ValueError` depending on when the error occurred. @@ -932,9 +932,9 @@ internal datetime representation; or use ``dates.datestr2num``. Axes3D ~~~~~~ -- `.axes3d.Axes3D.w_xaxis` -- `.axes3d.Axes3D.w_yaxis` -- `.axes3d.Axes3D.w_zaxis` +- ``.axes3d.Axes3D.w_xaxis`` +- ``.axes3d.Axes3D.w_yaxis`` +- ``.axes3d.Axes3D.w_zaxis`` Use ``axes3d.Axes3D.xaxis``, ``axes3d.Axes3D.yaxis`` and ``axes3d.Axes3D.zaxis`` instead. diff --git a/doc/api/prev_api_changes/api_changes_3.6.0/removals.rst b/doc/api/prev_api_changes/api_changes_3.6.0/removals.rst index b261fdb30596..1e128ef5e90d 100644 --- a/doc/api/prev_api_changes/api_changes_3.6.0/removals.rst +++ b/doc/api/prev_api_changes/api_changes_3.6.0/removals.rst @@ -94,7 +94,7 @@ The following module-level classes/variables have been removed: ``mathtext.latex_to_standard`` - ``mathtext.MathtextBackendPdf``, ``mathtext.MathtextBackendPs``, ``mathtext.MathtextBackendSvg``, ``mathtext.MathtextBackendCairo``; use - `.MathtextBackendPath` instead. + ``.MathtextBackendPath`` instead. - ``mathtext.Node`` and all its subclasses - ``mathtext.NUM_SIZE_LEVELS`` - ``mathtext.Parser`` diff --git a/doc/api/toolkits/mplot3d/axes3d.rst b/doc/api/toolkits/mplot3d/axes3d.rst index e334fee2fea5..6b83751aac2f 100644 --- a/doc/api/toolkits/mplot3d/axes3d.rst +++ b/doc/api/toolkits/mplot3d/axes3d.rst @@ -270,9 +270,6 @@ Aliases and deprecated methods tunit_cube tunit_edges unit_cube - w_xaxis - w_yaxis - w_zaxis Other diff --git a/doc/users/prev_whats_new/dflt_style_changes.rst b/doc/users/prev_whats_new/dflt_style_changes.rst index b36a1a343116..48ff86f56a73 100644 --- a/doc/users/prev_whats_new/dflt_style_changes.rst +++ b/doc/users/prev_whats_new/dflt_style_changes.rst @@ -575,7 +575,7 @@ default. The default face color is now ``'C0'`` instead of ``'b'``. ax_bottom.set_ylim(0, .75) ax_bottom.add_artist(mpatches.Rectangle(grid[1] - [0.025, 0.05], 0.05, 0.1)) - ax_bottom.add_artist(mpatches.RegularPolygon(grid[3], 5, 0.1)) + ax_bottom.add_artist(mpatches.RegularPolygon(grid[3], 5, radius=0.1)) ax_bottom.add_artist(mpatches.Ellipse(grid[4], 0.2, 0.1)) ax_bottom.add_artist(mpatches.Circle(grid[0], 0.1)) ax_bottom.axis('off') diff --git a/doc/users/prev_whats_new/whats_new_1.4.rst b/doc/users/prev_whats_new/whats_new_1.4.rst index febcb93047b9..057f547c9f4c 100644 --- a/doc/users/prev_whats_new/whats_new_1.4.rst +++ b/doc/users/prev_whats_new/whats_new_1.4.rst @@ -121,7 +121,7 @@ Support for strides in mlab Todd Jennings added some functions to mlab to make it easier to use NumPy strides to create memory-efficient 2D arrays. This includes ``matplotlib.mlab.stride_repeat``, which repeats an array to create a 2D -array, and :func:`~matplotlib.mlab.stride_windows`, which uses a moving window +array, and ``matplotlib.mlab.stride_windows``, which uses a moving window to create a 2D array from a 1D array. Formatter for new-style formatting strings diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index a38e11a53bf5..78290aceaab9 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -45,9 +45,6 @@ `detrend_none` Return the original line. - -`stride_windows` - Get all windows in an array in a memory-efficient manner """ import functools From 55b83c6c9e51d1d81a80317356d204a4ccbb4331 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sun, 15 Jan 2023 10:05:40 +0100 Subject: [PATCH 34/35] Add api change note --- .../next_api_changes/removals/24984-OG.rst | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 doc/api/next_api_changes/removals/24984-OG.rst diff --git a/doc/api/next_api_changes/removals/24984-OG.rst b/doc/api/next_api_changes/removals/24984-OG.rst new file mode 100644 index 000000000000..a10e4a076452 --- /dev/null +++ b/doc/api/next_api_changes/removals/24984-OG.rst @@ -0,0 +1,174 @@ +Parameters to ``plt.figure()`` and the ``Figure`` constructor +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +All parameters to `.pyplot.figure` and the `.Figure` constructor, other than +*num*, *figsize*, and *dpi*, are now keyword-only. + +``stem(..., use_line_collection=False)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +... is no longer supported. This was a compatibility fallback to a +former more inefficient representation of the stem lines. + +Positional / keyword arguments +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Passing all but the very few first arguments positionally in the constructors +of Artists is no longer possible. Most arguments are now keyword-only. + +The *emit* and *auto* parameters of ``set_xlim``, ``set_ylim``, +``set_zlim``, ``set_rlim`` are now keyword-only. + +The *transOffset* parameter of `.Collection.set_offset_transform` and the +various ``create_collection`` methods of legend handlers has been renamed to +*offset_transform* (consistently with the property name). + +``Axes.get_window_extent`` / ``Figure.get_window_extent`` accept only +*renderer*. This aligns the API with the general `.Artist.get_window_extent` +API. All other parameters were ignored anyway. + +Methods to set parameters in ``LogLocator`` and ``LogFormatter*`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In `~.LogFormatter` and derived subclasses, the methods ``base`` and +``label_minor`` for setting the respective parameter are removed and +replaced by ``set_base`` and ``set_label_minor``, respectively. + +In `~.LogLocator`, the methods ``base`` and ``subs`` for setting the respective +parameter are removed. Instead, use ``set_params(base=..., subs=...)``. + +``Axes.get_renderer_cache`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The canvas now takes care of the renderer and whether to cache it or not, +so the ````Axes.get_renderer_cache`` method is removed. The +alternative is to call ``axes.figure.canvas.get_renderer()``. + +Unused methods in ``Axis``, ``Tick``, ``XAxis``, and ``YAxis`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Tick.label`` is now removed. Use ``Tick.label1`` instead. + +The following methods are no longer used and removed without a replacement: + +- ``Axis.get_ticklabel_extents`` +- ``Tick.get_pad_pixels`` +- ``XAxis.get_text_heights`` +- ``YAxis.get_text_widths`` + +``mlab.stride_windows`` +~~~~~~~~~~~~~~~~~~~~~~~ + +... is removed. Use ``numpy.lib.stride_tricks.sliding_window_view`` instead. + +``Axes3D`` +~~~~~~~~~~ + +The ``dist`` attribute has been privatized. Use the *zoom* keyword argument in +`.Axes3D.set_box_aspect` instead. + +The ``w_xaxis``, ``w_yaxis``, and ``w_zaxis`` attributes are now removed. +Instead use ``xaxis``, ``yaxis``, and ``zaxis``. + +3D Axis +~~~~~~~ + +``mplot3d.axis3d.Axis.set_pane_pos`` is removed. This is an internal method +where the provided values are overwritten during drawing. Hence, it does not +serve any purpose to be directly accessible. + +The two helper functions ``mplot3d.axis3d.move_from_center`` and +``mplot3d.axis3d.tick_update_position`` are considered internal and deprecated. +If these are required, please vendor the code from the corresponding private +methods ``_move_from_center`` and ``_tick_update_position``. + +``checkdep_usetex`` removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This method was only intended to disable tests in case no latex install was +found. As such, it is considered to be private and for internal use only. + +Please vendor the code from a previous version if you need this. + +``date_ticker_factory`` removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``date_ticker_factory`` method in the `matplotlib.dates` module is +removed. Instead use `~.AutoDateLocator` and `~.AutoDateFormatter` for a +more flexible and scalable locator and formatter. + +If you need the exact ``date_ticker_factory`` behavior, please copy the code +from a previous version. + +``transforms.Affine2D.identity()`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +... is removed in favor of directly calling the `.Affine2D` constructor with +no arguments. + +Removals in ``testing.decorators`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The unused class ``CleanupTestCase`` and decorator ``cleanup`` are removed. +The function ``check_freetype_version`` is considered internal and removed. +Vendor the code from a previous version. + +``text.get_rotation()`` +~~~~~~~~~~~~~~~~~~~~~~~ + +... is removed with no replacement. Copy the previous implementation if +needed. + +Miscellaneous internals +~~~~~~~~~~~~~~~~~~~~~~~ + +- ``axes_grid1.axes_size.AddList``; use ``sum(sizes, start=Fixed(0))`` (for + example) to sum multiple size objects. +- ``axes_size.Padded``; use ``size + pad`` instead +- ``axes_size.SizeFromFunc``, ``axes_size.GetExtentHelper`` +- ``AxisArtistHelper.delta1`` and ``AxisArtistHelper.delta2`` +- ``axislines.GridHelperBase.new_gridlines`` and + ``axislines.Axes.new_gridlines`` +- ``_DummyAxis.dataLim`` and ``_DummyAxis.viewLim``; use + ``get_data_interval()``, ``set_data_interval()``, ``get_view_interval()``, + and ``set_view_interval()`` instead. +- ``ImageMagickBase.delay`` and ``ImageMagickBase.output_args`` +- ``MathtextBackend``, ``MathtextBackendAgg``, ``MathtextBackendPath``, + ``MathTextWarning`` +- ``TexManager.get_font_config``; it previously returned an internal hashed key + for used for caching purposes. +- ``TextToPath.get_texmanager``; directly construct a `.texmanager.TexManager` + instead. +- ``ticker.is_close_to_int``; use ``math.isclose(x, round(x))`` instead. +- ``ticker.is_decade``; use ``y = numpy.log(x)/numpy.log(base); + numpy.isclose(y, numpy.round(y))`` instead. + + +Backend-specific removals +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- ``backend_pdf.Name.hexify`` +- ``backend_pdf.Operator`` and ``backend_pdf.Op.op`` are removed in favor of + a single standard `enum.Enum` interface on `.backend_pdf.Op`. +- ``backend_pdf.fill``; vendor the code of the similarly named private + functions if you rely on these functions. +- ``backend_pgf.LatexManager.texcommand`` and + ``backend_pgf.LatexManager.latex_header`` +- ``backend_pgf.NO_ESCAPE`` +- ``backend_pgf.common_texification`` +- ``backend_pgf.get_fontspec`` +- ``backend_pgf.get_preamble`` +- ``backend_pgf.re_mathsep`` +- ``backend_pgf.writeln`` +- ``backend_ps.convert_psfrags`` +- ``backend_ps.quote_ps_string``; vendor the code of the similarly named + private functions if you rely on it. +- ``backend_svg.escape_attrib``; vendor the code of the similarly named private + functions if you rely on it. +- ``backend_svg.escape_cdata``; vendor the code of the similarly named private + functions if you rely on it. +- ``backend_svg.escape_comment``; vendor the code of the similarly named + private functions if you rely on it. +- ``backend_svg.short_float_fmt``; vendor the code of the similarly named + private functions if you rely on it. +- ``backend_svg.generate_transform`` and ``backend_svg.generate_css`` From c2b3f1fc6fccf3220192ba14fc4e210a4a4a9e62 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Mon, 6 Mar 2023 10:22:06 +0100 Subject: [PATCH 35/35] Take review comments into account --- .../next_api_changes/removals/24984-OG.rst | 2 +- lib/matplotlib/collections.py | 6 +- lib/matplotlib/mlab.py | 42 +++---------- lib/matplotlib/offsetbox.py | 3 +- lib/matplotlib/tests/test_mlab.py | 62 ------------------- lib/mpl_toolkits/mplot3d/axis3d.py | 11 +--- 6 files changed, 15 insertions(+), 111 deletions(-) diff --git a/doc/api/next_api_changes/removals/24984-OG.rst b/doc/api/next_api_changes/removals/24984-OG.rst index a10e4a076452..59d6d12ba926 100644 --- a/doc/api/next_api_changes/removals/24984-OG.rst +++ b/doc/api/next_api_changes/removals/24984-OG.rst @@ -41,7 +41,7 @@ parameter are removed. Instead, use ``set_params(base=..., subs=...)``. ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The canvas now takes care of the renderer and whether to cache it or not, -so the ````Axes.get_renderer_cache`` method is removed. The +so the ``Axes.get_renderer_cache`` method is removed. The alternative is to call ``axes.figure.canvas.get_renderer()``. Unused methods in ``Axis``, ``Tick``, ``XAxis``, and ``YAxis`` diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index c9ae4117b9bd..377345006dfd 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -11,7 +11,7 @@ import itertools import math -from numbers import Number +from numbers import Number, Real import warnings import numpy as np @@ -439,9 +439,9 @@ def set_pickradius(self, pickradius): pickradius : float Pick radius, in points. """ - if not isinstance(pickradius, Number): + if not isinstance(pickradius, Real): raise ValueError( - f"pickradius must be a number, not {pickradius!r}") + f"pickradius must be a real-valued number, not {pickradius!r}") self._pickradius = pickradius def get_pickradius(self): diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index 78290aceaab9..1948e6333e83 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -210,39 +210,6 @@ def detrend_linear(y): return y - (b*x + a) -def _stride_windows(x, n, noverlap=0): - """ - Get all windows of *x* with length *n* as a single array, - using strides to avoid data duplication. - - .. warning:: - - It is not safe to write to the output array. Multiple - elements may point to the same piece of memory, - so modifying one value may change others. - - Parameters - ---------- - x : 1D array or sequence - Array or sequence containing the data. - n : int - The number of data points in each window. - noverlap : int, default: 0 (no overlap) - The overlap between adjacent windows. - - References - ---------- - `stackoverflow: Rolling window for 1D arrays in Numpy? - `_ - `stackoverflow: Using strides for an efficient moving average filter - `_ - """ - if noverlap >= n: - raise ValueError('noverlap must be less than n') - return np.lib.stride_tricks.sliding_window_view( - x, n, axis=0)[::n - noverlap].T - - def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None, mode=None): @@ -272,6 +239,9 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, if NFFT is None: NFFT = 256 + if noverlap >= NFFT: + raise ValueError('noverlap must be less than NFFT') + if mode is None or mode == 'default': mode = 'psd' _api.check_in_list( @@ -334,7 +304,8 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, raise ValueError( "The window length must match the data's first dimension") - result = _stride_windows(x, NFFT, noverlap) + result = np.lib.stride_tricks.sliding_window_view( + x, NFFT, axis=0)[::NFFT - noverlap].T result = detrend(result, detrend_func, axis=0) result = result * window.reshape((-1, 1)) result = np.fft.fft(result, n=pad_to, axis=0)[:numFreqs, :] @@ -342,7 +313,8 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, if not same_data: # if same_data is False, mode must be 'psd' - resultY = _stride_windows(y, NFFT, noverlap) + resultY = np.lib.stride_tricks.sliding_window_view( + y, NFFT, axis=0)[::NFFT - noverlap].T resultY = detrend(resultY, detrend_func, axis=0) resultY = resultY * window.reshape((-1, 1)) resultY = np.fft.fft(resultY, n=pad_to, axis=0)[:numFreqs, :] diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index 64b2c7720664..77768e738351 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -1225,8 +1225,7 @@ def __str__(self): return f"AnnotationBbox({self.xy[0]:g},{self.xy[1]:g})" @_docstring.dedent_interpd - def __init__(self, offsetbox, xy, *, - xybox=None, + def __init__(self, offsetbox, xy, xybox=None, *, xycoords='data', boxcoords=None, frameon=True, pad=0.4, # FancyBboxPatch boxstyle. diff --git a/lib/matplotlib/tests/test_mlab.py b/lib/matplotlib/tests/test_mlab.py index 7f57f6f8c999..3b0d2529b5f1 100644 --- a/lib/matplotlib/tests/test_mlab.py +++ b/lib/matplotlib/tests/test_mlab.py @@ -6,68 +6,6 @@ from matplotlib import mlab -class TestStride: - def get_base(self, x): - y = x - while y.base is not None: - y = y.base - return y - - def calc_window_target(self, x, NFFT, noverlap=0): - """ - This is an adaptation of the original window extraction algorithm. - This is here to test to make sure the new implementation has the same - result. - """ - step = NFFT - noverlap - ind = np.arange(0, len(x) - NFFT + 1, step) - n = len(ind) - result = np.zeros((NFFT, n)) - - # do the ffts of the slices - for i in range(n): - result[:, i] = x[ind[i]:ind[i]+NFFT] - return result - - @pytest.mark.parametrize('n, noverlap', - [(2, 2), (2, 3)], - ids=['noverlap greater than n', - 'noverlap equal to n']) - def test_stride_windows_invalid_params(self, n, noverlap): - x = np.arange(10) - with pytest.raises(ValueError): - mlab._stride_windows(x, n, noverlap) - - @pytest.mark.parametrize('n, noverlap', - [(1, 0), (5, 0), (15, 2), (13, -3)], - ids=['n1-noverlap0', 'n5-noverlap0', - 'n15-noverlap2', 'n13-noverlapn3']) - def test_stride_windows(self, n, noverlap): - x = np.arange(100) - y = mlab._stride_windows(x, n, noverlap=noverlap) - - expected_shape = [0, 0] - expected_shape[0] = n - expected_shape[1] = 100 // (n - noverlap) - yt = self.calc_window_target(x, n, noverlap=noverlap) - - assert yt.shape == y.shape - assert_array_equal(yt, y) - assert tuple(expected_shape) == y.shape - assert self.get_base(y) is x - - def test_stride_windows_n32_noverlap0_unflatten(self): - n = 32 - x = np.arange(n)[np.newaxis] - x1 = np.tile(x, (21, 1)) - x2 = x1.flatten() - y = mlab._stride_windows(x2, n) - - x1 = x1.T - assert y.shape == x1.shape - assert_array_equal(y, x1) - - def test_window(): np.random.seed(0) n = 1000 diff --git a/lib/mpl_toolkits/mplot3d/axis3d.py b/lib/mpl_toolkits/mplot3d/axis3d.py index 729b98b1a4c5..32bddf755a9a 100644 --- a/lib/mpl_toolkits/mplot3d/axis3d.py +++ b/lib/mpl_toolkits/mplot3d/axis3d.py @@ -183,12 +183,6 @@ def get_minor_ticks(self, numticks=None): obj.set_transform(self.axes.transData) return ticks - def _set_pane_pos(self, xys): - xys = np.asarray(xys) - xys = xys[:, :2] - self.pane.xy = xys - self.stale = True - def set_pane_color(self, color, alpha=None): """ Set pane color. @@ -319,8 +313,9 @@ def draw_pane(self, renderer): plane = self._PLANES[2 * index] else: plane = self._PLANES[2 * index + 1] - xys = [tc[p] for p in plane] - self._set_pane_pos(xys) + xys = np.asarray([tc[p] for p in plane]) + xys = xys[:, :2] + self.pane.xy = xys self.pane.draw(renderer) renderer.close_group('pane3d') pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy