Skip to content

Commit

Permalink
return an empty stat_values list in the else
Browse files Browse the repository at this point in the history
  • Loading branch information
bikegeek committed Jan 6, 2025
1 parent e75efe9 commit 85e2e7d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions metcalcpy/agg_stat_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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}")
Expand All @@ -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
Expand Down

0 comments on commit 85e2e7d

Please sign in to comment.