From 0cd7c309d004a3b398fa9c4e0a046a9c42ac534d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 10 Jan 2023 00:58:13 -0500 Subject: [PATCH 1/2] Flatten cbook into a single file It was made a directory so that we could put deprecation machinery into its own file, but that has now moved to the private `_api` module. There's no need to put `cbook` code in its own directory now. --- lib/matplotlib/{cbook/__init__.py => cbook.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/matplotlib/{cbook/__init__.py => cbook.py} (100%) diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook.py similarity index 100% rename from lib/matplotlib/cbook/__init__.py rename to lib/matplotlib/cbook.py From 6731a004c91fef7da42fe54a47eb892551fa7401 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 10 Jan 2023 01:45:54 -0500 Subject: [PATCH 2/2] Expire deprecations from cbook --- .../next_api_changes/removals/24923-ES.rst | 15 +++++++ lib/matplotlib/cbook.py | 42 ------------------- 2 files changed, 15 insertions(+), 42 deletions(-) create mode 100644 doc/api/next_api_changes/removals/24923-ES.rst diff --git a/doc/api/next_api_changes/removals/24923-ES.rst b/doc/api/next_api_changes/removals/24923-ES.rst new file mode 100644 index 000000000000..fcab80e66e8d --- /dev/null +++ b/doc/api/next_api_changes/removals/24923-ES.rst @@ -0,0 +1,15 @@ +cbook removals +~~~~~~~~~~~~~~ + +- ``matplotlib.cbook.MatplotlibDeprecationWarning`` and + ``matplotlib.cbook.mplDeprecation`` are removed; use + `matplotlib.MatplotlibDeprecationWarning` instead. +- ``cbook.maxdict``; use the standard library ``functools.lru_cache`` instead. + +Groupers from ``get_shared_x_axes`` / ``get_shared_y_axes`` are immutable +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Modifications to the Groupers returned by ``get_shared_x_axes`` and +``get_shared_y_axes`` are no longer allowed. Note that previously, calling e.g. +``join()`` would already fail to set up the correct structures for sharing +axes; use `.Axes.sharex` or `.Axes.sharey` instead. diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py index 1e51f6a834cc..817034e2b042 100644 --- a/lib/matplotlib/cbook.py +++ b/lib/matplotlib/cbook.py @@ -30,19 +30,6 @@ from matplotlib import _api, _c_internal_utils -@_api.caching_module_getattr -class __getattr__: - # module-level deprecations - MatplotlibDeprecationWarning = _api.deprecated( - "3.6", obj_type="", - alternative="matplotlib.MatplotlibDeprecationWarning")( - property(lambda self: _api.deprecation.MatplotlibDeprecationWarning)) - mplDeprecation = _api.deprecated( - "3.6", obj_type="", - alternative="matplotlib.MatplotlibDeprecationWarning")( - property(lambda self: _api.deprecation.MatplotlibDeprecationWarning)) - - def _get_running_interactive_framework(): """ Return the interactive framework whose event loop is currently running, if @@ -578,27 +565,6 @@ def flatten(seq, scalarp=is_scalar_or_string): yield from flatten(item, scalarp) -@_api.deprecated("3.6", alternative="functools.lru_cache") -class maxdict(dict): - """ - A dictionary with a maximum size. - - Notes - ----- - This doesn't override all the relevant methods to constrain the size, - just ``__setitem__``, so use with caution. - """ - - def __init__(self, maxsize): - super().__init__() - self.maxsize = maxsize - - def __setitem__(self, k, v): - super().__setitem__(k, v) - while len(self) >= self.maxsize: - del self[next(iter(self))] - - class Stack: """ Stack of elements with a movable cursor. @@ -891,25 +857,17 @@ def __init__(self, grouper): self._grouper = grouper class _GrouperMethodForwarder: - def __init__(self, deprecated_kw=None): - self._deprecated_kw = deprecated_kw - def __set_name__(self, owner, name): wrapped = getattr(Grouper, name) forwarder = functools.wraps(wrapped)( lambda self, *args, **kwargs: wrapped( self._grouper, *args, **kwargs)) - if self._deprecated_kw: - forwarder = _api.deprecated(**self._deprecated_kw)(forwarder) setattr(owner, name, forwarder) __contains__ = _GrouperMethodForwarder() __iter__ = _GrouperMethodForwarder() joined = _GrouperMethodForwarder() get_siblings = _GrouperMethodForwarder() - clean = _GrouperMethodForwarder(deprecated_kw=dict(since="3.6")) - join = _GrouperMethodForwarder(deprecated_kw=dict(since="3.6")) - remove = _GrouperMethodForwarder(deprecated_kw=dict(since="3.6")) def simple_linear_interpolation(a, steps):