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

Skip to content

Commit 5622be2

Browse files
authored
Merge pull request #20806 from timhoffm/deprecate-lutsize
Deprecate matplotlib.cm.LUTSIZE
2 parents efdcfc2 + 015985f commit 5622be2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``matplotlib.cm.LUTSIZE``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~
3+
is deprecated. Use :rc:`image.lut` instead. This value only affects colormap
4+
quantization levels for default colormaps generated at module import time.

lib/matplotlib/cm.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""
1717

1818
from collections.abc import Mapping, MutableMapping
19+
import functools
1920

2021
import numpy as np
2122
from numpy import ma
@@ -26,7 +27,16 @@
2627
from matplotlib._cm_listed import cmaps as cmaps_listed
2728

2829

29-
LUTSIZE = mpl.rcParams['image.lut']
30+
# module-level deprecations.
31+
@functools.lru_cache(None)
32+
def __getattr__(name):
33+
if name == "LUTSIZE":
34+
_api.warn_deprecated("3.5", name=name,
35+
alternative="rcParams['image.lut']")
36+
return _LUTSIZE
37+
38+
39+
_LUTSIZE = mpl.rcParams['image.lut']
3040

3141

3242
def _gen_cmap_registry():
@@ -37,11 +47,11 @@ def _gen_cmap_registry():
3747
cmap_d = {**cmaps_listed}
3848
for name, spec in datad.items():
3949
cmap_d[name] = ( # Precache the cmaps at a fixed lutsize..
40-
colors.LinearSegmentedColormap(name, spec, LUTSIZE)
50+
colors.LinearSegmentedColormap(name, spec, _LUTSIZE)
4151
if 'red' in spec else
4252
colors.ListedColormap(spec['listed'], name)
4353
if 'listed' in spec else
44-
colors.LinearSegmentedColormap.from_list(name, spec, LUTSIZE))
54+
colors.LinearSegmentedColormap.from_list(name, spec, _LUTSIZE))
4555
# Generate reversed cmaps.
4656
for cmap in list(cmap_d.values()):
4757
rmap = cmap.reversed()

0 commit comments

Comments
 (0)