1010import six
1111
1212import os
13- import warnings as _warnings # To remove once spectral is removed
1413import numpy as np
1514from numpy import ma
1615import matplotlib as mpl
@@ -69,7 +68,8 @@ def _generate_cmap(name, lutsize):
6968 """Generates the requested cmap from its *name*. The lut size is
7069 *lutsize*."""
7170
72- spec = datad [name ]
71+ # Use superclass method to avoid deprecation warnings during initial load.
72+ spec = dict .__getitem__ (datad , name )
7373
7474 # Generate the colormap object.
7575 if 'red' in spec :
@@ -81,22 +81,18 @@ def _generate_cmap(name, lutsize):
8181
8282LUTSIZE = mpl .rcParams ['image.lut' ]
8383
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 )
10096
10197cmap_d .update (cmaps_listed )
10298
0 commit comments