Skip to content

Commit

Permalink
Enclose call to the METcalcpy sum_stat module's calculate_statistic t…
Browse files Browse the repository at this point in the history
…o capture error and log appropriately for success and failure
  • Loading branch information
bikegeek committed Oct 17, 2024
1 parent 6077a63 commit 2ebe88e
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,22 @@ def _calculate_tost_paired(self, series_data_1: DataFrame, series_data_2: DataFr
# calculate stat values
for index, row in series_data_1.iterrows():
row_array = np.expand_dims(row.to_numpy(), axis=0)
stat_value = calculate_statistic(row_array, series_data_1.columns,
stat_value = calculate_statistic( row_array, series_data_1.columns,
series_data_1["stat_name"][0].lower())
# save the value to the 'stat_value' column
series_data_1.at[index, 'stat_value'] = stat_value

for index, row in series_data_2.iterrows():
row_array = np.expand_dims(row.to_numpy(), axis=0)
stat_value = calculate_statistic(row_array, series_data_2.columns,
series_data_2["stat_name"][0].lower())
statistic_name = series_data_2["stat_name"][0].lower()
try:
logger.info(f"Calculating the '{statistic_name}' statistic using METcalcpy's sum_stat.py module, "
f"for data row: {index}.")
stat_value = calculate_statistic(row_array, series_data_2.columns,
statistic_name)
except RuntimeError:
logger.error(f"An error occurred while calculating the statistic '{statistic_name}'")

# save the value to the 'stat_value' column
series_data_2.at[index, 'stat_value'] = stat_value

Expand Down

0 comments on commit 2ebe88e

Please sign in to comment.