1616"""
1717
1818from collections .abc import Mapping , MutableMapping
19+ import functools
1920
2021import numpy as np
2122from numpy import ma
2627from 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
3242def _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