Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4356809

Browse files
committed
Merge pull request #5710 from tacaswell/fix_axproperties_warning
FIX: suppress warning in Artist.properties
2 parents 55ba992 + d6fdeba commit 4356809

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
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

Lines changed: 12 additions & 1 deletion
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)