Skip to content

Commit d6fdeba

Browse files
committed
FIX: suppress warning in Artist.properties
Calling `get_axes` currently raises a deprecating warning, eat this. The Artist.properties function will be completely re-written in 2.1 with traitlets so this is a reasonable stop-gap for now. closes matplotlib#5089
1 parent 227f0c4 commit d6fdeba

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/matplotlib/artist.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,9 @@ def properties(self):
12761276
continue
12771277

12781278
try:
1279-
val = func()
1279+
with warnings.catch_warnings():
1280+
warnings.simplefilter('ignore')
1281+
val = func()
12801282
except:
12811283
continue
12821284
else:

lib/matplotlib/tests/test_artist.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
3-
3+
import warnings
44
from matplotlib.externals import six
55

66
import io
@@ -9,6 +9,7 @@
99

1010
import matplotlib.pyplot as plt
1111
import matplotlib.patches as mpatches
12+
import matplotlib.lines as mlines
1213
import matplotlib.path as mpath
1314
import matplotlib.transforms as mtrans
1415
import matplotlib.collections as mcollections
@@ -176,6 +177,16 @@ def test_remove():
176177
assert_true(ax.stale)
177178

178179

180+
@cleanup
181+
def test_properties():
182+
ln = mlines.Line2D([], [])
183+
with warnings.catch_warnings(record=True) as w:
184+
# Cause all warnings to always be triggered.
185+
warnings.simplefilter("always")
186+
ln.properties()
187+
assert len(w) == 0
188+
189+
179190
if __name__ == '__main__':
180191
import nose
181192
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)