From 9c71ff7c06ad969aad61c86fb8ab83c23675cbe2 Mon Sep 17 00:00:00 2001 From: Sander Roet Date: Tue, 27 Feb 2024 18:25:11 +0100 Subject: [PATCH] restructure plotting import to be testable --- src/pytom_tm/plotting.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pytom_tm/plotting.py b/src/pytom_tm/plotting.py index cdbebc7e..6ef44f28 100644 --- a/src/pytom_tm/plotting.py +++ b/src/pytom_tm/plotting.py @@ -5,13 +5,13 @@ from scipy.optimize import curve_fit from scipy.special import erf -if find_spec("matplotlib") is None or find_spec("seaborn") is None: +try: + import matplotlib.pyplot as plt + import seaborn as sns +except ModuleNotFoundError: raise RuntimeError( "ROC estimation can only be done when matplotlib and seaborn are installed." ) -else: - import matplotlib.pyplot as plt - import seaborn as sns sns.set(context="talk", style="ticks")