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

Skip to content

Commit b51807d

Browse files
timhoffmtacaswell
authored andcommitted
Deprecate matplotlib.cm.LUTSIZE
we can directly use `mpl.rcParams['image.lut']`.
1 parent efdcfc2 commit b51807d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@
2626
from matplotlib._cm_listed import cmaps as cmaps_listed
2727

2828

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

3140

3241
def _gen_cmap_registry():
@@ -37,11 +46,11 @@ def _gen_cmap_registry():
3746
cmap_d = {**cmaps_listed}
3847
for name, spec in datad.items():
3948
cmap_d[name] = ( # Precache the cmaps at a fixed lutsize..
40-
colors.LinearSegmentedColormap(name, spec, LUTSIZE)
49+
colors.LinearSegmentedColormap(name, spec, _LUTSIZE)
4150
if 'red' in spec else
4251
colors.ListedColormap(spec['listed'], name)
4352
if 'listed' in spec else
44-
colors.LinearSegmentedColormap.from_list(name, spec, LUTSIZE))
53+
colors.LinearSegmentedColormap.from_list(name, spec, _LUTSIZE))
4554
# Generate reversed cmaps.
4655
for cmap in list(cmap_d.values()):
4756
rmap = cmap.reversed()

0 commit comments

Comments
 (0)