Skip to content

Make Deprecation Warning in matplotlib more useful #13352

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
HDembinski opened this issue Feb 3, 2019 · 2 comments
Closed

Make Deprecation Warning in matplotlib more useful #13352

HDembinski opened this issue Feb 3, 2019 · 2 comments

Comments

@HDembinski
Copy link

Bug report

Sources of deprecation warnings in matplotlib are hard to track down.

Code for reproduction

from matplotlib import pyplot as plt
plt.tick_params(left="False")

Actual outcome

/home/hdembinski/.local/lib/python3.7/site-packages/matplotlib/cbook/__init__.py:424: MatplotlibDeprecationWarning: 
Passing one of 'on', 'true', 'off', 'false' as a boolean is deprecated; use an actual boolean (True/False) instead.
  warn_deprecated("2.2", "Passing one of 'on', 'true', 'off', 'false' as a "

As you can see, there is no indication which line in my client code triggers the warning. If the script is long and not minimal, the origin is difficult to find.

Expected outcome
The deprecation warning should be enhanced with a backtrace of some sort, that allows me to find the call in my script which triggers the warning.

Matplotlib version

  • Matplotlib version: 3.0.2
  • Python version: 3.7.1
@jklymak
Copy link
Member

jklymak commented Feb 3, 2019

Thanks. The deprecation operator was recently improved:

from matplotlib import pyplot as plt
fig, ax = plt.subplots()
print(ax.aname)

returns the (hopefully) more helpful:

testdep.py:3: MatplotlibDeprecationWarning:
The aname attribute was deprecated in Matplotlib 3.1 and will be removed in 3.3.
  print(ax.aname)
Axes

This change came in #12152 and will be available when 3.1 is released (Feb/Mar timeframe).

I'll close as fixed.

@jklymak jklymak closed this as completed Feb 3, 2019
@HDembinski
Copy link
Author

Cool, thanks!

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