Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0cce49b

Browse filesBrowse files
authored
Merge pull request #12152 from anntzer/external-deprecation-warnings
Use _warn_external for deprecations warnings.
2 parents 1232fdf + f21ad20 commit 0cce49b
Copy full SHA for 0cce49b

File tree

3 files changed

+7
-4
lines changed
Filter options

3 files changed

+7
-4
lines changed

‎doc/users/dflt_style_changes.rst

Copy file name to clipboardExpand all lines: doc/users/dflt_style_changes.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ a cleaner separation between subplots.
10021002
with mpl.rc_context(rc=rcparams):
10031003

10041004
ax = fig.add_subplot(2, 2, j)
1005-
ax.hist(np.random.beta(0.5, 0.5, 10000), 25, normed=True)
1005+
ax.hist(np.random.beta(0.5, 0.5, 10000), 25, density=True)
10061006
ax.set_xlim([0, 1])
10071007
ax.set_title(title)
10081008

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,8 @@ def _warn_external(message, category=None):
19911991
frame = sys._getframe()
19921992
for stacklevel in itertools.count(1): # lgtm[py/unused-loop-variable]
19931993
if not re.match(r"\A(matplotlib|mpl_toolkits)(\Z|\.)",
1994-
frame.f_globals["__name__"]):
1994+
# Work around sphinx-gallery not setting __name__.
1995+
frame.f_globals.get("__name__", "")):
19951996
break
19961997
frame = frame.f_back
19971998
warnings.warn(message, category, stacklevel)

‎lib/matplotlib/cbook/deprecation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/deprecation.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def warn_deprecated(
109109
removal=removal)
110110
category = (PendingDeprecationWarning if pending
111111
else MatplotlibDeprecationWarning)
112-
warnings.warn(message, category, stacklevel=2)
112+
from . import _warn_external
113+
_warn_external(message, category)
113114

114115

115116
def deprecated(since, message='', name='', alternative='', pending=False,
@@ -216,7 +217,8 @@ def finalize(wrapper, new_doc):
216217
else MatplotlibDeprecationWarning)
217218

218219
def wrapper(*args, **kwargs):
219-
warnings.warn(message, category, stacklevel=2)
220+
from . import _warn_external
221+
_warn_external(message, category)
220222
return func(*args, **kwargs)
221223

222224
old_doc = textwrap.dedent(old_doc or '').strip('\n')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.