Skip to content

Commit

Permalink
Merge pull request #24923 from QuLogic/clean-cbook
Browse files Browse the repository at this point in the history
Cleanup cbook deprecations and layout
  • Loading branch information
anntzer committed Jan 10, 2023
2 parents e147ff1 + 6731a00 commit 18f493a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 42 deletions.
15 changes: 15 additions & 0 deletions doc/api/next_api_changes/removals/24923-ES.rst
Original file line number Diff line number Diff line change
@@ -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.
42 changes: 0 additions & 42 deletions lib/matplotlib/cbook/__init__.py → lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 18f493a

Please sign in to comment.