File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Original file line number Diff line number Diff line change @@ -83,8 +83,9 @@ def _generate_cmap(name, lutsize):
83
83
84
84
# We silence warnings here to avoid raising the deprecation warning for
85
85
# spectral/spectral_r when this module is imported.
86
- with _warnings .catch_warnings ():
86
+ with _warnings .catch_warnings (record = True ):
87
87
_warnings .simplefilter ("ignore" )
88
+ _wr = getattr (cbook , '__warningregistry__' , None )
88
89
# Generate the reversed specifications (all at once, to avoid
89
90
# modify-when-iterating).
90
91
datad .update ({cmapname + '_r' : _reverse_cmap_spec (spec )
@@ -95,6 +96,14 @@ def _generate_cmap(name, lutsize):
95
96
for cmapname in datad :
96
97
cmap_d [cmapname ] = _generate_cmap (cmapname , LUTSIZE )
97
98
99
+ # Work around Python 2.7 bug. See https://bugs.python.org/issue4180
100
+ # and http://stackoverflow.com/q/2390766
101
+ if _wr is not None :
102
+ cbook .__warningregistry__ .clear ()
103
+ cbook .__warningregistry__ .update (_wr )
104
+ else :
105
+ del cbook .__warningregistry__
106
+
98
107
cmap_d .update (cmaps_listed )
99
108
100
109
locals ().update (cmap_d )
You can’t perform that action at this time.
0 commit comments