10
10
import six
11
11
12
12
import os
13
- import warnings as _warnings # To remove once spectral is removed
14
13
import numpy as np
15
14
from numpy import ma
16
15
import matplotlib as mpl
@@ -69,7 +68,8 @@ def _generate_cmap(name, lutsize):
69
68
"""Generates the requested cmap from its *name*. The lut size is
70
69
*lutsize*."""
71
70
72
- spec = datad [name ]
71
+ # Use superclass method to avoid deprecation warnings during initial load.
72
+ spec = dict .__getitem__ (datad , name )
73
73
74
74
# Generate the colormap object.
75
75
if 'red' in spec :
@@ -81,22 +81,18 @@ def _generate_cmap(name, lutsize):
81
81
82
82
LUTSIZE = mpl .rcParams ['image.lut' ]
83
83
84
- # We silence warnings here to avoid raising the deprecation warning for
85
- # spectral/spectral_r when this module is imported.
86
- with _warnings .catch_warnings ():
87
- _warnings .simplefilter ("ignore" )
88
- # Generate the reversed specifications ...
89
- for cmapname in list (six .iterkeys (datad )):
90
- spec = datad [cmapname ]
91
- spec_reversed = _reverse_cmap_spec (spec )
92
- datad [cmapname + '_r' ] = spec_reversed
93
-
94
- # Precache the cmaps with ``lutsize = LUTSIZE`` ...
95
-
96
- # Use datad.keys() to also add the reversed ones added in the section
97
- # above:
98
- for cmapname in six .iterkeys (datad ):
99
- cmap_d [cmapname ] = _generate_cmap (cmapname , LUTSIZE )
84
+ # Generate the reversed specifications ...
85
+ for cmapname in list (six .iterkeys (datad )):
86
+ spec = datad [cmapname ]
87
+ spec_reversed = _reverse_cmap_spec (spec )
88
+ datad [cmapname + '_r' ] = spec_reversed
89
+
90
+ # Precache the cmaps with ``lutsize = LUTSIZE`` ...
91
+
92
+ # Use datad.keys() to also add the reversed ones added in the section
93
+ # above:
94
+ for cmapname in six .iterkeys (datad ):
95
+ cmap_d [cmapname ] = _generate_cmap (cmapname , LUTSIZE )
100
96
101
97
cmap_d .update (cmaps_listed )
102
98
0 commit comments