Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/api/next_api_changes/deprecations/28728-TH.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
matplotlib.validate_backend
~~~~~~~~~~~~~~~~~~~~~~~~~~~

...is deprecated. Please use `matplotlib.rcsetup.validate_backend` instead.


matplotlib.sanitize_sequence
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

...is deprecated. Please use `matplotlib.cbook.sanitize_sequence` instead.
20 changes: 14 additions & 6 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,8 @@
# cbook must import matplotlib only within function
# definitions, so it is safe to import from it here.
from . import _api, _version, cbook, _docstring, rcsetup
from matplotlib.cbook import sanitize_sequence
from matplotlib._api import MatplotlibDeprecationWarning
from matplotlib.rcsetup import cycler # noqa: F401
from matplotlib.rcsetup import validate_backend


_log = logging.getLogger(__name__)
Expand Down Expand Up @@ -1236,7 +1234,7 @@ def use(backend, *, force=True):
matplotlib.pyplot.switch_backend

"""
name = validate_backend(backend)
name = rcsetup.validate_backend(backend)
# don't (prematurely) resolve the "auto" backend setting
if rcParams._get_backend_or_none() == name:
# Nothing to do if the requested backend is already set
Expand Down Expand Up @@ -1340,7 +1338,7 @@ def _replacer(data, value):
except Exception:
# key does not exist, silently fall back to key
pass
return sanitize_sequence(value)
return cbook.sanitize_sequence(value)


def _label_from_arg(y, default_name):
Expand Down Expand Up @@ -1472,8 +1470,8 @@ def inner(ax, *args, data=None, **kwargs):
if data is None:
return func(
ax,
*map(sanitize_sequence, args),
**{k: sanitize_sequence(v) for k, v in kwargs.items()})
*map(cbook.sanitize_sequence, args),
**{k: cbook.sanitize_sequence(v) for k, v in kwargs.items()})

bound = new_sig.bind(ax, *args, **kwargs)
auto_label = (bound.arguments.get(label_namer)
Expand Down Expand Up @@ -1510,6 +1508,16 @@ def inner(ax, *args, data=None, **kwargs):
_log.debug('platform is %s', sys.platform)


@_api.deprecated("3.10", alternative="matplotlib.cbook.sanitize_sequence")
def sanitize_sequence(data):
return cbook.sanitize_sequence(data)


@_api.deprecated("3.10", alternative="matplotlib.rcsetup.validate_backend")
def validate_backend(s):
return rcsetup.validate_backend(s)


# workaround: we must defer colormaps import to after loading rcParams, because
# colormap creation depends on rcParams
from matplotlib.cm import _colormaps as colormaps # noqa: E402
Expand Down