From 85e2e7d7f7f5fb685284f173ef4f91a18c626688 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Mon, 6 Jan 2025 12:11:58 -0700 Subject: [PATCH] return an empty stat_values list in the else --- metcalcpy/agg_stat_bootstrap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metcalcpy/agg_stat_bootstrap.py b/metcalcpy/agg_stat_bootstrap.py index 93996e30..17188fda 100644 --- a/metcalcpy/agg_stat_bootstrap.py +++ b/metcalcpy/agg_stat_bootstrap.py @@ -295,7 +295,6 @@ def _calc_stats(self, cases): logger = self.logger func_name = f'calculate_{self.statistic}' safe_log(logger, "info", f"Starting statistic calculation using function: {func_name}") - stat_values = [] if cases is not None and cases.ndim == 2: # The single value case safe_log(logger, "debug", "Processing single-value case.") @@ -306,8 +305,8 @@ def _calc_stats(self, cases): values = self.series_data[np.in1d(data_cases, flat_cases)].to_numpy() safe_log(logger, "debug", f"Number of values selected for single case: {len(values)}") # Calculate the statistic for each bootstrap iteration - stat_values = [] try: + stat_values = [] stat_value = globals()[func_name](values, self.column_names, logger=logger) stat_values.append([stat_value]) safe_log(logger, "info", f"Statistic calculated for bootstrap iteration: {stat_value}") @@ -331,6 +330,7 @@ def _calc_stats(self, cases): safe_log(logger, "error", f"Error calculating statistic for bootstrap iteration: {e}") raise else: + stat_values = [] safe_log(logger, "error", "Invalid input for cases. Cannot calculate statistic.") raise KeyError("can't calculate statistic") return stat_values