Skip to content

Commit 9d47f0a

Browse files
Minimizing the warnigns on create recipe
1 parent 97df6fe commit 9d47f0a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

wfcommons/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
# the Free Software Foundation, either version 3 of the License, or
99
# (at your option) any later version.
1010

11+
import warnings
12+
warnings.filterwarnings('ignore')
13+
1114
import json
1215
import logging
1316
import math
1417
import pathlib
1518
import scipy.stats
16-
import warnings
1719
import numpy as np
1820
import operator as op
1921

@@ -82,8 +84,6 @@ def best_fit_distribution(data: List[float], logger: Optional[Logger] = None) ->
8284
for dist_name in distribution_names:
8385
# Ignore warnings from data that can't be fit
8486
with warnings.catch_warnings():
85-
warnings.filterwarnings('ignore')
86-
8787
try:
8888
distribution = getattr(scipy.stats, dist_name)
8989
params = distribution.fit(y)
@@ -98,7 +98,7 @@ def best_fit_distribution(data: List[float], logger: Optional[Logger] = None) ->
9898
best_params = params
9999
best_sse = sse
100100
except Exception as e:
101-
print(f"WARNING: distribution \"{dist_name}\" failed ({e})")
101+
logger.warning(f"WARNING: distribution \"{dist_name}\" failed ({e})")
102102

103103
logger.debug(f'Best distribution fit: {best_distribution}')
104104
return best_distribution, best_params

0 commit comments

Comments
 (0)