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,19 +81,15 @@ 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 (all at once, to avoid
89- # modify-when-iterating).
90- datad .update ({cmapname + '_r' : _reverse_cmap_spec (spec )
91- for cmapname , spec in six .iteritems (datad )})
92-
93- # Precache the cmaps with ``lutsize = LUTSIZE``.
94- # Also add the reversed ones added in the section above:
95- for cmapname in datad :
96- cmap_d [cmapname ] = _generate_cmap (cmapname , LUTSIZE )
84+ # Generate the reversed specifications (all at once, to avoid
85+ # modify-when-iterating).
86+ datad .update ({cmapname + '_r' : _reverse_cmap_spec (spec )
87+ for cmapname , spec in six .iteritems (datad )})
88+
89+ # Precache the cmaps with ``lutsize = LUTSIZE``.
90+ # Also add the reversed ones added in the section above:
91+ for cmapname in datad :
92+ cmap_d [cmapname ] = _generate_cmap (cmapname , LUTSIZE )
9793
9894cmap_d .update (cmaps_listed )
9995
0 commit comments