Skip to content

Commit

Permalink
Ensure returning NaNs when less than 3 points in correlation metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
hectornieto committed Mar 28, 2022
1 parent 88709fa commit 68d0f7e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions model_evaluation/double_collocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ def agreement_metrics(obs, pre):

# Remove of any existing NaN in any of the collocated systems
obs, pre = remove_nans(obs, pre)

cor, p_value = st.pearsonr(obs, pre)
slope, intercept = st.linregress(obs, pre)[:2]
if np.size(obs) > 2:
cor, p_value = st.pearsonr(obs, pre)
slope, intercept = st.linregress(obs, pre)[:2]
else:
cor, p_value, slope, intercept = np.nan, np.nan, np.nan, np._financial_names

obs_hat = np.mean(obs)
pre_prime = pre - obs_hat
Expand Down Expand Up @@ -156,6 +158,8 @@ def rmse_wilmott_decomposition(obs, pre):

# Remove of any existing NaN in any of the collocated systems
obs, pre = remove_nans(obs, pre)
if np.size(obs) <= 2:
return np.nan, np.nan

slope, intercept = st.linregress(obs, pre)[:2]

Expand Down

0 comments on commit 68d0f7e

Please sign in to comment.