From 9d47f0a31f119d3ad6aaf0e2424f4afe2cf3f190 Mon Sep 17 00:00:00 2001 From: Taina Coleman Date: Tue, 10 Sep 2024 12:28:10 -0700 Subject: [PATCH] Minimizing the warnigns on create recipe --- wfcommons/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wfcommons/utils.py b/wfcommons/utils.py index ece04a40..4a20d414 100644 --- a/wfcommons/utils.py +++ b/wfcommons/utils.py @@ -8,12 +8,14 @@ # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. +import warnings +warnings.filterwarnings('ignore') + import json import logging import math import pathlib import scipy.stats -import warnings import numpy as np import operator as op @@ -82,8 +84,6 @@ def best_fit_distribution(data: List[float], logger: Optional[Logger] = None) -> for dist_name in distribution_names: # Ignore warnings from data that can't be fit with warnings.catch_warnings(): - warnings.filterwarnings('ignore') - try: distribution = getattr(scipy.stats, dist_name) params = distribution.fit(y) @@ -98,7 +98,7 @@ def best_fit_distribution(data: List[float], logger: Optional[Logger] = None) -> best_params = params best_sse = sse except Exception as e: - print(f"WARNING: distribution \"{dist_name}\" failed ({e})") + logger.warning(f"WARNING: distribution \"{dist_name}\" failed ({e})") logger.debug(f'Best distribution fit: {best_distribution}') return best_distribution, best_params