Skip to content

Commit c0bfd18

Browse files
ignore matplotlib deprecations
1 parent 17f55f8 commit c0bfd18

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

nutils/export.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ def mplfigure(name, /, **kwargs):
2626
:class:`matplotlib.figure.Figure` object.
2727
'''
2828

29-
import matplotlib.figure
30-
import matplotlib.backends.backend_agg
29+
with warnings.ignore(DeprecationWarning):
30+
import matplotlib.figure
31+
import matplotlib.backends.backend_agg
3132
fig = matplotlib.figure.Figure(**kwargs)
3233
with log.userfile(name, 'wb') as f:
3334
yield fig

nutils/warnings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,11 @@ def via(print):
3131
warnings.showwarning = oldshowwarning
3232

3333

34+
@contextlib.contextmanager
35+
def ignore(category=Warning):
36+
with warnings.catch_warnings():
37+
warnings.simplefilter("ignore", category)
38+
yield
39+
40+
3441
# vim:sw=4:sts=4:et

0 commit comments

Comments
 (0)