MAINT deprecated 'spectral' in favor of 'nipy_spectral' #7416

Merged
merged 6 commits into from Nov 10, 2016

Conversation

Projects
None yet
5 participants
Contributor

NelleV commented Nov 6, 2016

This raises a deprecation warning for the deprecated "spectral" colormap.
I think I covered all the possible calls to "spectral".

closes #7315

Contributor

NelleV commented Nov 6, 2016

@Carreau Do you want to review? :)

NelleV added the needs_review label Nov 6, 2016

Contributor

Carreau commented Nov 6, 2016 edited

@Carreau Do you want to review? :)

Yes :-) The name vas changed in 2012, so I would not be shy as marking as deprecated since at least matplotlib 1.5.

You might want to warn on spectral_r as well (constructed in lib/matplotlib/cm.py)

For post 2.0 / Subsequent PRs:

  • It might be hard, but add a warning filter that turns use of spectral during testing (and doc building ?) into an error.
  • Have keys(), iterkeys(), items() not list spectral and spectral_r

An easy implementation would be to actually remove the data find the dict, and if name==spectral, return super().__getattra__('nipy_spectral_'). But that can be done later.

Contributor

Carreau commented Nov 6, 2016

doc/users/image_tutorial.rst uses spectral...

Contributor

NelleV commented Nov 6, 2016

Yeah, I forgot to look at the documentation and "fix" it…

Contributor

Carreau commented Nov 6, 2016

Sorry I'm slow to review I'm in the train, tethering and the car is shaking quite a bit.

Contributor

NelleV commented Nov 7, 2016

Updated it to deprecate spectral_r as well.

Owner

efiring commented Nov 7, 2016

Looks OK to me.

lib/matplotlib/_cm.py
+ name="spectral",
+ alternative="nipy_spectral",
+ obj_type="colormap"
+ )
@Carreau

Carreau Nov 7, 2016

Contributor

do you want to make the message dynamic for spectral_r as well ? I can see pros and cons to both.

@NelleV

NelleV Nov 7, 2016

Contributor

I was going to be lazy, and not do it, but… maybe I should.

@Carreau

Carreau approved these changes Nov 7, 2016

from matplotlib._cm import cubehelix
from matplotlib._cm_listed import cmaps as cmaps_listed
-cmap_d = dict()
+cmap_d = _deprecation_datad()
@Carreau

Carreau Nov 7, 2016

Contributor

Note that line 88 of this file will likely trigger the deprecation warning if I'm not wrong, as it loop through all the colormap to build the reversed ones. Not sure what we can do about the though. Just pointing it out.

@NelleV

NelleV Nov 7, 2016

Contributor

argh… you are right.
I'll fix that.

Contributor

Carreau commented Nov 7, 2016

Updated it to deprecate spectral_r as well.

+1. Thanks @NelleV !

Contributor

NelleV commented Nov 7, 2016

I'm now catching warnings when creating the reverse colormaps to avoid raising the deprecation warning when cm.py is imported (ie, when anyone uses matplotlib).

Owner

tacaswell commented Nov 8, 2016

Do we want to also deprecate spectral function in pyplot as well?

Contributor

NelleV commented Nov 8, 2016

Yes, we should… but how to do this with the function being generated?

Owner

tacaswell commented Nov 8, 2016

https://github.com/matplotlib/matplotlib/blob/v2.x/boilerplate.py#L333 split the list into two (deprecated and not) and make a new template which includes the deprecation warning.

Contributor

NelleV commented Nov 8, 2016

Got it. I'll do that.

NelleV added some commits Nov 6, 2016

@NelleV NelleV MAINT deprecated 'spectral' in favor of 'nipy_spectral'
closes #7315
c708871
@NelleV NelleV DOC spectral is now deprecated in favor of nipy_spectral
The documentation now uses nipy_spectral
066cfe0
@NelleV NelleV MAINT Deprecated spectral_r as well 6d7aaee
@NelleV NelleV MAINT catches deprecation warning when importing cm.py
We don't want to raise the deprecation warning for spectral/spectral_r unless
the user calls that colormap.
c5738e2
@NelleV NelleV MAINT deprecated spectral function as well
5de2f95
Contributor

NelleV commented Nov 9, 2016

Should I run boilerplate and commit the function as well or should we wait for the release?

Owner

efiring commented Nov 9, 2016

Yes, it's best to keep pyplot in sync with everything else.

@NelleV NelleV MAINT updated pyplot with new boilerplate script
954bf7a

tacaswell changed the title from MAINT deprecated 'spectral' in favor of 'nipy_spectral' to [MRG+1] MAINT deprecated 'spectral' in favor of 'nipy_spectral' Nov 9, 2016

Member

QuLogic commented Nov 9, 2016

Wow, pyplot.py seems to be pretty outdated; will have to be careful when backporting.

Owner

tacaswell commented Nov 9, 2016

Should probably just re-run boilerplate after doing the backport.

@efiring efiring merged commit 660aa65 into matplotlib:master Nov 10, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.0002%) to 61.832%
Details

efiring changed the title from [MRG+1] MAINT deprecated 'spectral' in favor of 'nipy_spectral' to MAINT deprecated 'spectral' in favor of 'nipy_spectral' Nov 10, 2016

@efiring efiring added a commit that referenced this pull request Nov 10, 2016

@efiring efiring backport: Merge pull request #7416 from NelleV/7315_spectral
MAINT deprecated 'spectral' in favor of 'nipy_spectral'

boilerplate.py was run after using 'git cherry-pick -n -m1 660aa65'
f87100a
Owner

efiring commented Nov 10, 2016

backported as f87100a (including the pyplot.py regenerated by boilerplate.py)

efiring removed the needs_review label Nov 10, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment