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

Silence plot warnings #4365

Merged
merged 5 commits into from
Aug 24, 2020
Merged

Conversation

mathause
Copy link
Collaborator

@mathause mathause commented Aug 21, 2020

  • Towards Warnings in the test suite #3266
  • Tests added
  • Passes isort . && black . && mypy . && flake8
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

I gave a try to silence some of the warning for the plotting functions. I brought it down from 67 to 5 (4 of which come from external libraries).

  • MatplotlibDeprecationWarning: The 'extend' parameter to Colorbar has no effect because it is overridden by the mappable; it is deprecated since 3.3 and will be removed two minor releases later.
  • MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("viridis"))
  • MatplotlibDeprecationWarning: Passing parameters norm and vmin/vmax simultaneously is deprecated since 3.3 and will become an error two minor releases later. Please pass vmin/vmax directly to the norm when creating it.
  • MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3. Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading']. This will become an error two minor releases later. See plt.pcolormesh will infer interval breaks per default #4364
  • UserWarning: Requested projection is different from current axis projection, creating new axis with requested projection.
  • Made sure all figures are closed at the end of a test.
  • Added a meta-test to ensure all figures will be closed if tests are added in the future

I cannot exclude that one of these changes has an effect on the plots that is not tested in the suite... Tests pass locally for py38 and py36-bare-minimum.

Copy link
Contributor

@dcherian dcherian left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @mathause

@@ -291,6 +291,11 @@ def _determine_cmap_params(
cmap, newnorm = _build_discrete_cmap(cmap, levels, extend, filled)
norm = newnorm if norm is None else norm

# vmin & vmax needs to be None if norm is passed
Copy link
Contributor

@dcherian dcherian Aug 21, 2020

Choose a reason for hiding this comment

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

I wonder if we can cleanup this function a bit by always returning a norm with vmin, vmax specified. But that can be a future PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes that would be nice. I did not know which the default norm would be...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the default is mpl.colors.Normalize.

@max-sixty
Copy link
Collaborator

Nice! Thanks a lot @mathause

@keewis
Copy link
Collaborator

keewis commented Aug 24, 2020

the upstream-dev CI failure seems to be caused by pypi.anaconda.org being down?

@mathause
Copy link
Collaborator Author

mathause commented Aug 24, 2020

I switched to assert_array_equal (from numpy.testing). I think this should be fine for the tested arrays here.

I'll leave the norm/ vmin/ vmaxas is - that would require more effort.

@dcherian
Copy link
Contributor

Thanks @mathause

@dcherian dcherian merged commit d3536b9 into pydata:master Aug 24, 2020
@mathause mathause deleted the silence_plot_warnings branch August 24, 2020 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants