Skip to content

Commit 04fea8c

Browse files
committed
MNT: Deprecate reimported functions in top-level namespace
1 parent 7a2ea1c commit 04fea8c

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
matplotlib.validate_backend
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
...is deprecated. Please use `matplotlib.rcsetup.validate_backend` instead.
5+
6+
7+
matplotlib.sanitize_sequence
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
10+
...is deprecated. Please use `matplotlib.cbook.sanitize_sequence` instead.

lib/matplotlib/__init__.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,8 @@
157157
# cbook must import matplotlib only within function
158158
# definitions, so it is safe to import from it here.
159159
from . import _api, _version, cbook, _docstring, rcsetup
160-
from matplotlib.cbook import sanitize_sequence
161160
from matplotlib._api import MatplotlibDeprecationWarning
162161
from matplotlib.rcsetup import cycler # noqa: F401
163-
from matplotlib.rcsetup import validate_backend
164162

165163

166164
_log = logging.getLogger(__name__)
@@ -1236,7 +1234,7 @@ def use(backend, *, force=True):
12361234
matplotlib.pyplot.switch_backend
12371235
12381236
"""
1239-
name = validate_backend(backend)
1237+
name = rcsetup.validate_backend(backend)
12401238
# don't (prematurely) resolve the "auto" backend setting
12411239
if rcParams._get_backend_or_none() == name:
12421240
# Nothing to do if the requested backend is already set
@@ -1340,7 +1338,7 @@ def _replacer(data, value):
13401338
except Exception:
13411339
# key does not exist, silently fall back to key
13421340
pass
1343-
return sanitize_sequence(value)
1341+
return cbook.sanitize_sequence(value)
13441342

13451343

13461344
def _label_from_arg(y, default_name):
@@ -1472,8 +1470,8 @@ def inner(ax, *args, data=None, **kwargs):
14721470
if data is None:
14731471
return func(
14741472
ax,
1475-
*map(sanitize_sequence, args),
1476-
**{k: sanitize_sequence(v) for k, v in kwargs.items()})
1473+
*map(cbook.sanitize_sequence, args),
1474+
**{k: cbook.sanitize_sequence(v) for k, v in kwargs.items()})
14771475

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

15121510

1511+
@_api.deprecated("3.10", alternative="matplotlib.cbook.sanitize_sequence")
1512+
def sanitize_sequence(data):
1513+
return cbook.sanitize_sequence(data)
1514+
1515+
1516+
@_api.deprecated("3.10", alternative="matplotlib.rcsetup.validate_backend")
1517+
def validate_backend(s):
1518+
return rcsetup.validate_backend(s)
1519+
1520+
15131521
# workaround: we must defer colormaps import to after loading rcParams, because
15141522
# colormap creation depends on rcParams
15151523
from matplotlib.cm import _colormaps as colormaps # noqa: E402

0 commit comments

Comments
 (0)