Skip to content

Commit c4ee605

Browse files
authored
fix: Suppress RunTime warnings for negative size values (#6744)
1 parent 349a4cf commit c4ee605

2 files changed

Lines changed: 9 additions & 9 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: 8 additions & 8 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
@@ -163,13 +164,12 @@ def _figure_data(self, plot, fmt, bbox_inches='tight', as_script=False, **kwargs
163164
)
164165
kw.update(kwargs)
165166

166-
# 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)
167+
with np.errstate(invalid="ignore"):
168+
with suppress(Exception):
169+
# Attempts to precompute the tight bounding box
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)