Skip to content

Commit 0403c6a

Browse files
committed
Ruff linting/formatting
1 parent 8b27e37 commit 0403c6a

File tree

5 files changed

+178
-180
lines changed

5 files changed

+178
-180
lines changed

pygem/bin/run/run_calibration.py

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,9 @@ def run(list_packed_vars):
636636

637637
# Tidewater glaciers - use climatic mass balance since calving_k already calibrated separately
638638
if gdir.is_tidewater:
639-
assert (
640-
'mb_clim_mwea' in gdir.mbdata.keys()
641-
), 'include_frontalablation is set as true, but fontal ablation has yet to be calibrated.'
639+
assert 'mb_clim_mwea' in gdir.mbdata.keys(), (
640+
'include_frontalablation is set as true, but fontal ablation has yet to be calibrated.'
641+
)
642642
mb_obs_mwea = gdir.mbdata['mb_clim_mwea']
643643
mb_obs_mwea_err = gdir.mbdata['mb_clim_mwea_err']
644644
# non-tidewater - use geodetic mass balance
@@ -702,9 +702,9 @@ def run(list_packed_vars):
702702
fls = None
703703

704704
if debug:
705-
assert os.path.exists(
706-
mbdata_fn
707-
), 'Mass balance data missing. Check dataset and column names'
705+
assert os.path.exists(mbdata_fn), (
706+
'Mass balance data missing. Check dataset and column names'
707+
)
708708

709709
# if spinup, grab appropriate flowlines
710710
if args.spinup:
@@ -1207,9 +1207,9 @@ def single_param_optimizer(
12071207
12081208
Computationally more robust and sometimes faster than scipy minimize
12091209
"""
1210-
assert (
1211-
prm2opt is not None
1212-
), 'For single_param_optimizer you must specify parameter to optimize'
1210+
assert prm2opt is not None, (
1211+
'For single_param_optimizer you must specify parameter to optimize'
1212+
)
12131213

12141214
if prm2opt == 'kp':
12151215
prm_bndlow = kp_bnds[0]
@@ -1707,9 +1707,9 @@ def single_param_optimizer(
17071707
+ glacier_str.split('.')[0].zfill(2)
17081708
+ '/'
17091709
)
1710-
assert os.path.exists(
1711-
em_mod_fp + em_mod_fn
1712-
), f'emulator output does not exist : {em_mod_fp + em_mod_fn}'
1710+
assert os.path.exists(em_mod_fp + em_mod_fn), (
1711+
f'emulator output does not exist : {em_mod_fp + em_mod_fn}'
1712+
)
17131713
mbEmulator = massbalEmulator.load(em_mod_path=em_mod_fp + em_mod_fn)
17141714
outpath_sfix = '' # output file path suffix if using emulator
17151715
else:
@@ -2039,24 +2039,18 @@ def must_melt(kp, tbias, ddfsnow, **kwargs):
20392039
sampler = mcmc.Metropolis(mb.means, mb.stds)
20402040

20412041
# draw samples
2042-
(
2043-
m_chain_z,
2044-
pred_chain,
2045-
m_primes_z,
2046-
pred_primes,
2047-
_,
2048-
ar,
2049-
) = sampler.sample(
2050-
initial_guesses_z,
2051-
mb.log_posterior,
2052-
n_samples=args.chain_length,
2053-
h=pygem_prms['calib']['MCMC_params']['mcmc_step'],
2054-
burnin=int(args.burn_pct / 100 * args.chain_length),
2055-
thin_factor=pygem_prms['calib']['MCMC_params'][
2056-
'thin_interval'
2057-
],
2058-
progress_bar=args.progress_bar,
2059-
)
2042+
m_chain_z, pred_chain, m_primes_z, pred_primes, _, ar = (
2043+
sampler.sample(
2044+
initial_guesses_z,
2045+
mb.log_posterior,
2046+
n_samples=args.chain_length,
2047+
h=pygem_prms['calib']['MCMC_params']['mcmc_step'],
2048+
burnin=int(args.burn_pct / 100 * args.chain_length),
2049+
thin_factor=pygem_prms['calib']['MCMC_params'][
2050+
'thin_interval'
2051+
],
2052+
progress_bar=args.progress_bar,
2053+
)
20602054

20612055
# Check condition at the end
20622056
if (m_chain_z[:, 0] == m_chain_z[0, 0]).all():
@@ -2331,9 +2325,9 @@ def single_param_optimizer(
23312325
mb_mwea_threshold=0.005,
23322326
debug=False,
23332327
):
2334-
assert (
2335-
prm2opt is not None
2336-
), 'For single_param_optimizer you must specify parameter to optimize'
2328+
assert prm2opt is not None, (
2329+
'For single_param_optimizer you must specify parameter to optimize'
2330+
)
23372331

23382332
if prm2opt == 'kp':
23392333
prm_bndlow = kp_bnds[0]

0 commit comments

Comments
 (0)