From 2faf8964833373056477a5ae3eff7d8ffa42c108 Mon Sep 17 00:00:00 2001 From: Robert Haase Date: Sun, 12 May 2024 14:07:56 +0200 Subject: [PATCH] mute warnings when showing images using repr_html --- pyclesperanto_prototype/_tier0/_array_operators.py | 3 ++- pyclesperanto_prototype/_tier9/_imshow.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pyclesperanto_prototype/_tier0/_array_operators.py b/pyclesperanto_prototype/_tier0/_array_operators.py index cb7d95b3..364e2bce 100644 --- a/pyclesperanto_prototype/_tier0/_array_operators.py +++ b/pyclesperanto_prototype/_tier0/_array_operators.py @@ -441,7 +441,8 @@ def _repr_html_(self): imshow(self, labels=labels, continue_drawing=True, - colorbar=not labels) + colorbar=not labels, + mute_warning=True) image = self._png_to_html(self._plt_to_png()) else: return "
cle.array(" + str(np.asarray(self)) + ", dtype=" + str(self.dtype) + ")
" diff --git a/pyclesperanto_prototype/_tier9/_imshow.py b/pyclesperanto_prototype/_tier9/_imshow.py index 94c3927f..ee3dec98 100644 --- a/pyclesperanto_prototype/_tier9/_imshow.py +++ b/pyclesperanto_prototype/_tier9/_imshow.py @@ -1,7 +1,7 @@ from .._tier0 import Image, plugin_function @plugin_function -def imshow(image : Image, title : str = None, labels : bool = False, min_display_intensity : float = None, max_display_intensity : float = None, color_map = None, plot = None, colorbar:bool = False, colormap = None, alpha:float = None, continue_drawing:bool = False): +def imshow(image : Image, title : str = None, labels : bool = False, min_display_intensity : float = None, max_display_intensity : float = None, color_map = None, plot = None, colorbar:bool = False, colormap = None, alpha:float = None, continue_drawing:bool = False, mute_warning:bool=False): """Visualize an image, e.g. in Jupyter notebooks. Parameters @@ -30,8 +30,9 @@ def imshow(image : Image, title : str = None, labels : bool = False, min_display continue_drawing: float True: the next shown image can be visualized on top of the current one, e.g. with alpha = 0.5 """ - import warnings - warnings.warn("cle.imshow is deprecated, use stackview.imshow instead.") + if not mute_warning: + import warnings + warnings.warn("cle.imshow is deprecated, use stackview.imshow instead.") import numpy as np from .._tier0 import pull from .._tier1 import maximum_z_projection