Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport spectral/spectral_r deprecations fixes from #7857 #7982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import six

import os
import warnings as _warnings # To remove once spectral is removed
import numpy as np
from numpy import ma
import matplotlib as mpl
Expand Down Expand Up @@ -69,7 +68,8 @@ def _generate_cmap(name, lutsize):
"""Generates the requested cmap from its *name*. The lut size is
*lutsize*."""

spec = datad[name]
# Use superclass method to avoid deprecation warnings during initial load.
spec = dict.__getitem__(datad, name)

# Generate the colormap object.
if 'red' in spec:
Expand All @@ -81,22 +81,18 @@ def _generate_cmap(name, lutsize):

LUTSIZE = mpl.rcParams['image.lut']

# We silence warnings here to avoid raising the deprecation warning for
# spectral/spectral_r when this module is imported.
with _warnings.catch_warnings():
_warnings.simplefilter("ignore")
# Generate the reversed specifications ...
for cmapname in list(six.iterkeys(datad)):
spec = datad[cmapname]
spec_reversed = _reverse_cmap_spec(spec)
datad[cmapname + '_r'] = spec_reversed

# Precache the cmaps with ``lutsize = LUTSIZE`` ...

# Use datad.keys() to also add the reversed ones added in the section
# above:
for cmapname in six.iterkeys(datad):
cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE)
# Generate the reversed specifications ...
for cmapname in list(six.iterkeys(datad)):
spec = datad[cmapname]
spec_reversed = _reverse_cmap_spec(spec)
datad[cmapname + '_r'] = spec_reversed

# Precache the cmaps with ``lutsize = LUTSIZE`` ...

# Use datad.keys() to also add the reversed ones added in the section
# above:
for cmapname in six.iterkeys(datad):
cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE)

cmap_d.update(cmaps_listed)

Expand Down