Skip to content

Commit ab6d04b

Browse files
committed
run: more informative error when sampler mis/non-specified
1 parent e59880f commit ab6d04b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cobaya/run.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ def run(info):
4545
# END OF DEPRECATION BLOCK
4646
# 1. Prepare output driver, if requested by defining an output_prefix
4747
# GetDist needs to know the original sampler, so don't overwrite if minimizer
48-
which_sampler = list(info["sampler"])[0]
48+
try:
49+
which_sampler = list(info["sampler"])[0]
50+
except (KeyError, TypeError):
51+
raise LoggedError(
52+
logger_run, "You need to specify a sampler using the 'sampler' key as e.g. "
53+
"`sampler: {mcmc: None}.`")
4954
infix = "minimize" if which_sampler == "minimize" else None
5055
output = get_output(prefix=info.get(_output_prefix), resume=info.get(_resume),
5156
force=info.get(_force), infix=infix)

0 commit comments

Comments
 (0)