16
16
"""
17
17
18
18
from collections .abc import Mapping , MutableMapping
19
+ import functools
19
20
20
21
import numpy as np
21
22
from numpy import ma
26
27
from matplotlib ._cm_listed import cmaps as cmaps_listed
27
28
28
29
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' ]
30
40
31
41
32
42
def _gen_cmap_registry ():
@@ -37,11 +47,11 @@ def _gen_cmap_registry():
37
47
cmap_d = {** cmaps_listed }
38
48
for name , spec in datad .items ():
39
49
cmap_d [name ] = ( # Precache the cmaps at a fixed lutsize..
40
- colors .LinearSegmentedColormap (name , spec , LUTSIZE )
50
+ colors .LinearSegmentedColormap (name , spec , _LUTSIZE )
41
51
if 'red' in spec else
42
52
colors .ListedColormap (spec ['listed' ], name )
43
53
if 'listed' in spec else
44
- colors .LinearSegmentedColormap .from_list (name , spec , LUTSIZE ))
54
+ colors .LinearSegmentedColormap .from_list (name , spec , _LUTSIZE ))
45
55
# Generate reversed cmaps.
46
56
for cmap in list (cmap_d .values ()):
47
57
rmap = cmap .reversed ()
0 commit comments