Skip to content
Snippets Groups Projects
Commit 6cff44ee authored by Alan De Smet's avatar Alan De Smet Committed by Eva Schiffer
Browse files

Resolve "RuntimeWarning with stats when stddev==0.0"

parent b7fd24b6
No related branches found
No related tags found
No related merge requests found
...@@ -115,7 +115,11 @@ def compute_correlation(xData, yData, goodMask, compute_r_function=pearsonr): ...@@ -115,7 +115,11 @@ def compute_correlation(xData, yData, goodMask, compute_r_function=pearsonr):
# if we have enough data, try to build the correlation # if we have enough data, try to build the correlation
toReturn = numpy.nan toReturn = numpy.nan
if (good_x_data.size >= 2) and (good_y_data.size >= 2) : if (good_x_data.size >= 2) and (good_y_data.size >= 2) :
toReturn = compute_r_function(good_x_data, good_y_data)[0] with numpy.warnings.catch_warnings():
# If the standard deviation of good_y_data is 0.0,
# a warning is generated. Suppress it.
numpy.warnings.filterwarnings('ignore', r'invalid value encountered in float_scalars', RuntimeWarning)
toReturn = compute_r_function(good_x_data, good_y_data)[0]
return toReturn return toReturn
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment