Skip to content

Commit

Permalink
Handled TCA CI bootstrapping error
Browse files Browse the repository at this point in the history
  • Loading branch information
pstradio committed Dec 16, 2021
1 parent a5edd0b commit f481c3c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/pytesmo/validation_framework/metric_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,10 +1738,16 @@ def calc_metrics(self, data, gpi_info):
for j, metric in enumerate(["snr", "err_std", "beta"]):
result[(metric, name)][0] = res[j][i]
else:
res = tcol_metrics_with_bootstrapped_ci(*arrays)
for i, name in enumerate(ds_names):
for j, metric in enumerate(["snr", "err_std", "beta"]):
result[(metric, name)][0] = res[j][0][i]
result[(metric + "_ci_lower", name)][0] = res[j][1][i]
result[(metric + "_ci_upper", name)][0] = res[j][2][i]
try:
# handle failing bootstrapping because e.g.
# too small sample size
res = tcol_metrics_with_bootstrapped_ci(*arrays)
for i, name in enumerate(ds_names):
for j, metric in enumerate(["snr", "err_std", "beta"]):
result[(metric, name)][0] = res[j][0][i]
result[(metric + "_ci_lower", name)][0] = res[j][1][i]
result[(metric + "_ci_upper", name)][0] = res[j][2][i]
except ValueError:
# if the calculation fails, the template results (np.nan) are used
pass
return result

0 comments on commit f481c3c

Please sign in to comment.