Skip to content
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

Move sunpy.cm to sunpy.visualization.colormaps #3410

Merged
merged 8 commits into from
Oct 30, 2019
Merged

Conversation

Cadair
Copy link
Member

@Cadair Cadair commented Oct 15, 2019

Fixes #3392

@ghost
Copy link

ghost commented Oct 15, 2019

Thanks for the pull request @Cadair! Everything looks great!

@pep8speaks
Copy link

pep8speaks commented Oct 15, 2019

Hello @Cadair! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 7:101: E501 line too long (108 > 100 characters)
Line 12:1: E402 module level import not at top of file
Line 18:1: E402 module level import not at top of file
Line 19:1: E402 module level import not at top of file
Line 26:1: E402 module level import not at top of file

Comment last updated at 2019-10-30 18:01:46 UTC

@Cadair Cadair added this to the 1.1 milestone Oct 15, 2019
@Cadair Cadair marked this pull request as ready for review October 16, 2019 16:49
@Cadair Cadair added the visualization Affects the visualization submodule label Oct 16, 2019
@Cadair Cadair requested a review from a team October 16, 2019 16:52
Copy link
Member

@ayshih ayshih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Also update docs/dev_guide/sunpy_stability.yaml
  • I suggest preserving the show_colormaps() figure in the code reference or docstring for sunpy.visualization.colormaps, unless there's a good reason not to

@Cadair Cadair requested a review from ayshih October 22, 2019 21:34
Copy link
Member

@ayshih ayshih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

One more thing: it's beyond the scope of this PR, but it's fairly opaque how to use this package. The colormaps themselves are held in a list (cmlist), but this fact isn't documented anywhere. Are we intentionally avoiding providing access like sunpy.visualization.colormaps.sdoaia171?

sunpy/cm/__init__.py Outdated Show resolved Hide resolved
sunpy/cm/__init__.py Show resolved Hide resolved
@Cadair
Copy link
Member Author

Cadair commented Oct 23, 2019

So another fun thing, we define an __all__ list in sunpy.visualization.colormaps.cm which excludes 99% of the objects in there, so only show_colormaps and cmlist (which isn't a list) get imported.

This is pretty much fine with the deprecated version, but what now doesn't work is this:

In [7]: from sunpy.cm.cm import sdoaia191                                                                                                                                                                                          
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-c83856b488f1> in <module>
----> 1 from sunpy.cm.cm import sdoaia191

ModuleNotFoundError: No module named 'sunpy.cm.cm'

@ayshih
Copy link
Member

ayshih commented Oct 23, 2019

Ha ha, of course, cmlist isn't a list. Awesome.

So, sunpy.cm.cm.sdoaia171 works, but from sunpy.cm.cm import sdoaia171 doesn't. Okay.

@Cadair
Copy link
Member Author

Cadair commented Oct 23, 2019

Ha ha, of course, cmlist isn't a list. Awesome.

This might actually be a good time to change it.

So, sunpy.cm.cm.sdoaia171 works, but from sunpy.cm.cm import sdoaia171 doesn't. Okay.

Are we happy with this, because it did work before this change?

sunpy/cm/__init__.py Outdated Show resolved Hide resolved
@Cadair
Copy link
Member Author

Cadair commented Oct 24, 2019

Ok, with a little bit of high grade hackery, I fixed the import from issue. So if the CI agrees I think this is good to go.

@ayshih
Copy link
Member

ayshih commented Oct 24, 2019

The figure-test build is still broken, though...

@nabobalis
Copy link
Contributor

______________________________________________________________________ ERROR collecting sunpy/cm/__init__.py _______________________________________________________________________
sunpy/cm/__init__.py:9: in <module>
    category=_SDW)
E   sunpy.util.exceptions.SunpyDeprecationWarning: The functionality of the sunpy.cm module is now in sunpy.visualization.colormaps as of SunPy 1.1. The ability to import sunpy.cm as a module may be removed in a future version of SunPy.

Breaking on raising the DepWarn.

@ayshih
Copy link
Member

ayshih commented Oct 24, 2019

Yeah, the open question during the dev meeting was why the figure-test build encounters that problem when collecting tests, but not, for example, the 32-bit build.

Copy link
Member

@ayshih ayshih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't be merged until the issue with the figure-test build is resolved

Comment on lines +24 to +28
# Import the two original functions in this namespace and use __all__ to keep
# import * behaviour the same.
from sunpy.visualization.colormaps.cm import *

__all__ = ['show_colormaps', 'cmlist']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, you're changing the behavior of from sunpy.cm import *, but that's because it didn't previously have an __all__. (For example, cmname would get imported.) However, the previous behavior is essentially a bug, and no one would have relied on it, so I support this change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is only cname.

This __all__ is copied from sunpy.cm.cm.__all__ which we were importing with import *

@ayshih ayshih self-requested a review October 28, 2019 20:55
sunpy/cm/__init__.py Outdated Show resolved Hide resolved
@Cadair
Copy link
Member Author

Cadair commented Oct 30, 2019

Can someone else please review this and then merge it

@@ -1,6 +1,3 @@
cm:
status: mature
comments: Only forwards compatible changes expected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

@dstansby dstansby merged commit 8670203 into sunpy:master Oct 30, 2019
@Cadair Cadair deleted the move_cm branch October 31, 2019 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
visualization Affects the visualization submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move cm subpackage into visualization subpackage
7 participants