From f481c3cbafc37b299d0227d815a7a24e3cf44792 Mon Sep 17 00:00:00 2001 From: Pietro Stradiotti Date: Thu, 16 Dec 2021 13:46:29 +0100 Subject: [PATCH] Handled TCA CI bootstrapping error --- .../validation_framework/metric_calculators.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pytesmo/validation_framework/metric_calculators.py b/src/pytesmo/validation_framework/metric_calculators.py index 2411e057..9ac04d8f 100644 --- a/src/pytesmo/validation_framework/metric_calculators.py +++ b/src/pytesmo/validation_framework/metric_calculators.py @@ -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