Skip to content

Commit f3b1925

Browse files
committed
suppress when calling
1 parent e86baca commit f3b1925

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

holoviews/plotting/mpl/element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def init_artists(self, ax, plot_args, plot_kwargs):
660660
if 'norm' in plot_kwargs: # vmin/vmax should now be exclusively in norm
661661
plot_kwargs.pop('vmin', None)
662662
plot_kwargs.pop('vmax', None)
663-
with warnings.catch_warnings():
663+
with (warnings.catch_warnings(), np.errstate(invalid="ignore")):
664664
# scatter have a default cmap and with an empty array will emit this warning
665665
warnings.filterwarnings('ignore', "No data for colormapping provided via 'c'")
666666
artist = plot_fn(*plot_args, **plot_kwargs)

holoviews/plotting/mpl/renderer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import base64
22
import os
3-
from contextlib import contextmanager
3+
from contextlib import contextmanager, suppress
44
from io import BytesIO
55
from itertools import chain
66
from tempfile import NamedTemporaryFile
77

88
import matplotlib as mpl
9+
import numpy as np
910
import param
1011
from matplotlib import pyplot as plt
1112
from param.parameterized import bothmethod
@@ -164,12 +165,11 @@ def _figure_data(self, plot, fmt, bbox_inches='tight', as_script=False, **kwargs
164165
kw.update(kwargs)
165166

166167
# Attempts to precompute the tight bounding box
167-
try:
168-
kw = self._compute_bbox(fig, kw)
169-
except Exception:
170-
pass
171-
bytes_io = BytesIO()
172-
fig.canvas.print_figure(bytes_io, **kw)
168+
with np.errstate(invalid="ignore"):
169+
with suppress(Exception):
170+
kw = self._compute_bbox(fig, kw)
171+
bytes_io = BytesIO()
172+
fig.canvas.print_figure(bytes_io, **kw)
173173
data = bytes_io.getvalue()
174174

175175
if as_script:

0 commit comments

Comments
 (0)