|
10 | 10 | import six
|
11 | 11 |
|
12 | 12 | import os
|
13 |
| - |
| 13 | +import warnings as _warnings # To remove once spectral is removed |
14 | 14 | import numpy as np
|
15 | 15 | from numpy import ma
|
16 | 16 | import matplotlib as mpl
|
@@ -81,17 +81,22 @@ def _generate_cmap(name, lutsize):
|
81 | 81 |
|
82 | 82 | LUTSIZE = mpl.rcParams['image.lut']
|
83 | 83 |
|
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 above: |
93 |
| -for cmapname in six.iterkeys(datad): |
94 |
| - cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE) |
| 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) |
95 | 100 |
|
96 | 101 | cmap_d.update(cmaps_listed)
|
97 | 102 |
|
|
0 commit comments