Skip to content

Commit

Permalink
Syntax edits
Browse files Browse the repository at this point in the history
  • Loading branch information
ishita9 committed Sep 18, 2024
1 parent 78c7f8c commit c87728d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion metcalcpy/agg_eclv.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _get_bootstrapped_stats(self, series_data, thresholds):
save_data=False,
block_length=block_length,
eclv=True
)
)
logger.info(f"Bootstrapped statistics calculated for threshold {thresh}.")
except KeyError as err:
logger.error(f"Failed to calculate bootstrapped statistics due to missing key: {err}", exc_info=True)
Expand Down
3 changes: 2 additions & 1 deletion metcalcpy/agg_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,8 @@ def _get_bootstrapped_stats_for_derived(self, series, distributions, axis="1"):
alpha=self.params['alpha'],
save_data=False,
save_distributions=(derived_curve_component.derived_operation == 'DIFF_SIG'),
block_length=block_length)
block_length=block_length
)
except KeyError as err:
logger.error(f"Error during bootstrapping: {err}", exc_info=True)
return BootstrapResults(None, None, None)
Expand Down
8 changes: 4 additions & 4 deletions metcalcpy/calc_difficulty_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def safe_log(logger, log_method, message):
if logger:
log_method(message)

def _input_check(sigmaij, muij, threshold, fieldijn, sigma_over_mu_ref, under_factor, logger):
def _input_check(logger, sigmaij, muij, threshold, fieldijn, sigma_over_mu_ref, under_factor):
"""
Check for valid input to _difficulty_index.
Expand Down Expand Up @@ -93,7 +93,7 @@ def _input_check(sigmaij, muij, threshold, fieldijn, sigma_over_mu_ref, under_fa
assert 0.0 <= under_factor <= 1.0
safe_log(logger, logger.debug, "under_factor is valid and within range.")

def _difficulty_index(sigmaij, muij, threshold, fieldijn, Aplin, sigma_over_mu_ref=EPS, under_factor=0.5, logger):
def _difficulty_index(logger, sigmaij, muij, threshold, fieldijn, Aplin, sigma_over_mu_ref=EPS, under_factor=0.5):
"""
Calculates version 6.1 of forecast difficulty index.
The threshold terms all penalize equal (or slightly unequal) spread.
Expand Down Expand Up @@ -160,8 +160,8 @@ def _difficulty_index(sigmaij, muij, threshold, fieldijn, Aplin, sigma_over_mu_r
return dij


def forecast_difficulty(sigmaij, muij, threshold, fieldijn,
Aplin, sigma_over_mu_ref=EPS, logger):
def forecast_difficulty(logger, sigmaij, muij, threshold, fieldijn,
Aplin, sigma_over_mu_ref=EPS):
"""
Calls private function _difficulty_index,
to calculate version (v6.1) of forecast difficulty index.
Expand Down
12 changes: 6 additions & 6 deletions test/test_calc_difficulty_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def test_forecast_difficulty():
thresh_eps = 2.0
kwargs = {'thresh_eps': thresh_eps, 'threshold_type': 'proximity'}

assert 0.9095608641027515 == forecast_difficulty(sigmaij, muij, threshold, fieldijn,
Aplin=None, sigma_over_mu_ref=EPS, None)[0][0]
assert 0.8191620255148825 == forecast_difficulty(sigmaij, muij, threshold, fieldijn,
Aplin=None, sigma_over_mu_ref=EPS, None)[8][17]
assert 1.227707670365556 == forecast_difficulty(sigmaij, muij, threshold, fieldijn,
Aplin=None, sigma_over_mu_ref=EPS, None)[4][9]
assert 0.9095608641027515 == forecast_difficulty(None, sigmaij, muij, threshold, fieldijn,
Aplin=None, sigma_over_mu_ref=EPS)[0][0]
assert 0.8191620255148825 == forecast_difficulty(None, sigmaij, muij, threshold, fieldijn,
Aplin=None, sigma_over_mu_ref=EPS)[8][17]
assert 1.227707670365556 == forecast_difficulty(None, sigmaij, muij, threshold, fieldijn,
Aplin=None, sigma_over_mu_ref=EPS)[4][9]


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion test/test_scorecard.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def settings():
'NoahMPv3.5.1_d01']},
'stat_flag': 'NCAR',
'sum_stat_input': f'{cwd}/data/scorecard.data',
'sum_stat_output': f'{cwd}/data/scorecard_output.data'
'sum_stat_output': f'{cwd}/data/scorecard_output.data',
'log_dir': f'{cwd}/logs/',
'log_filename': 'log_scorecard.txt',
'log_level': 'WARNING'
Expand Down

0 comments on commit c87728d

Please sign in to comment.