Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7dea129

Browse files
committed
Removed deprecated register_cmap, unregister_cmap, and get_cmap
1 parent 93cab2e commit 7dea129

2 files changed

Lines changed: 0 additions & 95 deletions

File tree

lib/matplotlib/cm.py

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -231,50 +231,6 @@ def get_cmap(self, cmap):
231231
globals().update(_colormaps)
232232

233233

234-
@_api.deprecated("3.7", alternative="``matplotlib.colormaps.register(name)``")
235-
def register_cmap(name=None, cmap=None, *, override_builtin=False):
236-
"""
237-
Add a colormap to the set recognized by :func:`get_cmap`.
238-
239-
Register a new colormap to be accessed by name ::
240-
241-
LinearSegmentedColormap('swirly', data, lut)
242-
register_cmap(cmap=swirly_cmap)
243-
244-
Parameters
245-
----------
246-
name : str, optional
247-
The name that can be used in :func:`get_cmap` or :rc:`image.cmap`
248-
249-
If absent, the name will be the :attr:`~matplotlib.colors.Colormap.name`
250-
attribute of the *cmap*.
251-
252-
cmap : matplotlib.colors.Colormap
253-
Despite being the second argument and having a default value, this
254-
is a required argument.
255-
256-
override_builtin : bool
257-
258-
Allow built-in colormaps to be overridden by a user-supplied
259-
colormap.
260-
261-
Please do not use this unless you are sure you need it.
262-
"""
263-
_api.check_isinstance((str, None), name=name)
264-
if name is None:
265-
try:
266-
name = cmap.name
267-
except AttributeError as err:
268-
raise ValueError("Arguments must include a name or a "
269-
"Colormap") from err
270-
# override_builtin is allowed here for backward compatibility
271-
# this is just a shim to enable that to work privately in
272-
# the global ColormapRegistry
273-
_colormaps._allow_override_builtin = override_builtin
274-
_colormaps.register(cmap, name=name, force=override_builtin)
275-
_colormaps._allow_override_builtin = False
276-
277-
278234
def _get_cmap(name=None, lut=None):
279235
"""
280236
Get a colormap instance, defaulting to rc values if *name* is None.
@@ -303,56 +259,6 @@ def _get_cmap(name=None, lut=None):
303259
else:
304260
return _colormaps[name].resampled(lut)
305261

306-
# do it in two steps like this so we can have an un-deprecated version in
307-
# pyplot.
308-
get_cmap = _api.deprecated(
309-
'3.7',
310-
name='get_cmap',
311-
alternative=(
312-
"``matplotlib.colormaps[name]`` " +
313-
"or ``matplotlib.colormaps.get_cmap(obj)``"
314-
)
315-
)(_get_cmap)
316-
317-
318-
@_api.deprecated("3.7",
319-
alternative="``matplotlib.colormaps.unregister(name)``")
320-
def unregister_cmap(name):
321-
"""
322-
Remove a colormap recognized by :func:`get_cmap`.
323-
324-
You may not remove built-in colormaps.
325-
326-
If the named colormap is not registered, returns with no error, raises
327-
if you try to de-register a default colormap.
328-
329-
.. warning::
330-
331-
Colormap names are currently a shared namespace that may be used
332-
by multiple packages. Use `unregister_cmap` only if you know you
333-
have registered that name before. In particular, do not
334-
unregister just in case to clean the name before registering a
335-
new colormap.
336-
337-
Parameters
338-
----------
339-
name : str
340-
The name of the colormap to be un-registered
341-
342-
Returns
343-
-------
344-
ColorMap or None
345-
If the colormap was registered, return it if not return `None`
346-
347-
Raises
348-
------
349-
ValueError
350-
If you try to de-register a default built-in colormap.
351-
"""
352-
cmap = _colormaps.get(name, None)
353-
_colormaps.unregister(name)
354-
return cmap
355-
356262

357263
def _auto_norm_from_scale(scale_cls):
358264
"""

lib/matplotlib/pyplot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
from matplotlib.scale import get_scale_names
7474

7575
from matplotlib.cm import _colormaps
76-
from matplotlib.cm import register_cmap # type: ignore
7776
from matplotlib.colors import _color_sequences
7877

7978
import numpy as np

0 commit comments

Comments
 (0)