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

Matplotlib deprecation warnings #464

Open
DanShort12 opened this issue Jun 17, 2020 · 3 comments
Open

Matplotlib deprecation warnings #464

DanShort12 opened this issue Jun 17, 2020 · 3 comments

Comments

@DanShort12
Copy link

Hi all,

As well as the rcParams overwrite, mentioned in #460, we see quite a few MatplotlibDeprecationWarning messages when using matplotlib 3.1.2. These stem from lines like below (of which I think there are 5 occurrences):

curr_rc = dict(matplotlib.rcParams)

Where Python will access all of the rcParams in that copy, and so matplotlib will think that any deprecated values are being read. It is possible to copy the rcParams without hitting this warning by calling as below:

curr_rc = matplotlib.rcParams.copy()

That method for getting around this is borrowed from matplotlib/matplotlib#15781.

Apologies, I see the fix for #460 is already in PR #461, I should have probably bundled this observation in with the last issue that I raised.

@GiudGiud
Copy link
Contributor

Hi Dan

There was already a fix for this in develop, with instead of "curr_rc = dict(matplotlib.rcParams)" in plotter.py, there was a slightly modified copy of the dictionary that was already removing some deprecated settings.

Your fix is better however, as it handles automatically the list of deprecated settings, I'm adding it to PR #461

Thanks!

@GiudGiud
Copy link
Contributor

GiudGiud commented Jun 17, 2020

It seems the deprecation warnings still appear because of the line
matplotlib.rcParams.update(curr_rc)
as curr_rc still contains the deprecated parameters (.copy() was silencing warnings, not removing them)

matplotlib/matplotlib#13118 mentions this. The fix implemented catches the deprecation warnings using the warnings library.

@DanShort12
Copy link
Author

Ah, I see that the update would also perform a similar access to rcParams, which would generate the warnings too. Catching the warnings when you perform the update seems like a sensible approach to me - that way you'd still get warnings if a deprecated parameter was used elsewhere. Cheers!

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

No branches or pull requests

2 participants