8000 MatplotlibDeprecationWarning examples.directory is deprecated · Issue #15781 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MatplotlibDeprecationWarning examples.directory is deprecated #15781

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

Closed
pllim opened this issue Nov 27, 2019 · 1 comment · Fixed by #21042
Closed

MatplotlibDeprecationWarning examples.directory is deprecated #15781

pllim opened this issue Nov 27, 2019 · 1 comment · Fixed by #21042

Comments

@pllim
Copy link
pllim commented Nov 27, 2019

Bug report

Bug summary

When running tests in astropy that import matplotlib, this warning appears, causing CI to fail when we turn warnings into errors, as shown below. I also see this warning when running the tests locally (though pytest complains about it, it did not result in error during test collection 🤷‍♀ ).

astropy/conftest.py:35: in pytest_configure
    matplotlibrc_cache.update(matplotlib.rcParams)
.../matplotlib/__init__.py:886: in __getitem__
    cbook.warn_deprecated(
.../matplotlib/cbook/deprecation.py:112: in warn_deprecated
    warnings.warn(message, category, stacklevel=2)
E   matplotlib.cbook.deprecation.MatplotlibDeprecationWarning: 
E   examples.directory is deprecated; in the future, examples will be found relative to the 'datapath' directory.

Code for reproduction

See astropy/astropy#9690

Actual outcome

Traceback as described above.

Expected outcome

No warning emitted, as it was supposedly fixed in #12658 .

Matplotlib version

  • Operating system: Various
  • Matplotlib version: 2.x and 3.x
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg (on local Windows 10 machine)
  • Python version: 3.7
  • Jupyter version (if applicable): N/A
  • Other libraries: astropy and its test dependencies

pip installed into a conda environment (on local machine)

@anntzer
Copy link
Contributor
anntzer commented Nov 28, 2019

The problem doesn't exist in master anymore because examples.directory has been removed, but for future reference, you can use rcParams.copy() to turn the rcParams into a plain dict that doesnt warn on access. Alternatively, I would say the "correct" way to do the manipulation you do in pytest_{,un}configure is to use rc_context() (which also suppresses the warnings, and is faster when restoring the previous settings because it knows it doesn't need to revalidate them), but that's admittedly a but annoying because pytest_{,un}configure is split over two functions (probably something doable with ExitStack, yada yada).
I'm not really sure there's a way around this problem given that we want to warn when people use deprecated rcs, so I think this is closer to a feature than a bug... (the fact that copy() has an "escape latch" could in fact nearly be considered a bug)

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

Successfully merging a pull request may close this issue.

3 participants
0