From 35c698a72f7d05e24dd9c1cc4840d77dde24dbab Mon Sep 17 00:00:00 2001 From: stnava Date: Thu, 25 Jan 2024 10:08:38 -0500 Subject: [PATCH] STYLE: convert an error to a warning. --- ants/viz/plot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ants/viz/plot.py b/ants/viz/plot.py index 7656ccfc..188132a6 100644 --- a/ants/viz/plot.py +++ b/ants/viz/plot.py @@ -2286,8 +2286,6 @@ def reorient_slice(x, axis): x = mirror_matrix(x) return x - # need this hack because of a weird NaN warning from matplotlib with overlays - warnings.simplefilter("ignore") # handle `image` argument if isinstance(image, str): @@ -2295,7 +2293,12 @@ def reorient_slice(x, axis): if not isinstance(image, iio.ANTsImage): raise ValueError("image argument must be an ANTsImage") - assert image.sum() > 0, "Image must be non-zero" + if not image.sum() > 0: + warnings.warn("Image must be non-zero. will not plot.") + return + + # need this hack because of a weird NaN warning from matplotlib with overlays + warnings.simplefilter("ignore") if (image.pixeltype not in {"float", "double"}) or (image.is_rgb): scale = False # turn off scaling if image is discrete