diff --git a/src/pytesmo/validation_framework/metric_calculators.py b/src/pytesmo/validation_framework/metric_calculators.py index ae93c0a..32208f0 100644 --- a/src/pytesmo/validation_framework/metric_calculators.py +++ b/src/pytesmo/validation_framework/metric_calculators.py @@ -1790,8 +1790,8 @@ def calc_metrics(self, data, gpi_info): 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] + result["status"][0] = eh.OK except ValueError: # if the calculation fails, the template results (np.nan) are used - pass - result["status"][0] = eh.OK + result["status"] = eh.METRICS_CALCULATION_FAILED return result diff --git a/tests/test_validation_framework/test_metric_calculators.py b/tests/test_validation_framework/test_metric_calculators.py index cd3c698..3929cf9 100644 --- a/tests/test_validation_framework/test_metric_calculators.py +++ b/tests/test_validation_framework/test_metric_calculators.py @@ -38,6 +38,7 @@ from pytesmo.metrics import with_analytical_ci, with_bootstrapped_ci, pairwise from pytesmo.validation_framework.validation import Validation +import pytesmo.validation_framework.error_handling as eh from pytesmo.validation_framework.metric_calculators import ( MetadataMetrics, BasicMetrics, @@ -1179,6 +1180,20 @@ def test_temporal_matching_ascat_ismn(): assert old_results[old_key]["n_obs"] == new_results[new_key]["n_obs"] +def test_TripleCollocationMetrics_failure(): + """ + Test if TripleCollocationMetrics returns the correct status attribute if + there is not enough data for bootstrapping. + """ + df = make_some_data() + data = df.iloc[0:50][["ref", "k1", "k2"]] + + triplet_metrics_calculator = TripleCollocationMetrics( + "ref", bootstrap_cis=True + ) + res = triplet_metrics_calculator.calc_metrics(data, gpi_info=(0, 0, 0)) + assert res["status"] == eh.METRICS_CALCULATION_FAILED + # def test_sorting_issue(): # GH #220 # might be a good start for fixing the issue