Skip to content

Commit 83fc014

Browse files
authored
Raise exception sampling scenarios/policies while no uncertainties/levers are defined (#282)
raise exception when sampling scenarios or policies while no uncertainties or levers are defined.
1 parent 3b68895 commit 83fc014

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ema_workbench/em_framework/samplers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
BooleanParameter,
2121
CategoricalParameter,
2222
)
23+
from ema_workbench.util.ema_exceptions import EMAError
2324

2425
# Created on 16 aug. 2011
2526
#
@@ -526,6 +527,10 @@ def sample_levers(models, n_samples, union=True, sampler=LHSSampler()):
526527
527528
"""
528529
levers = determine_parameters(models, "levers", union=union)
530+
531+
if not levers:
532+
raise EMAError("you are trying to sample policies, but no levers have been defined")
533+
529534
return sample_parameters(levers, n_samples, sampler, Policy)
530535

531536

@@ -547,6 +552,10 @@ def sample_uncertainties(models, n_samples, union=True, sampler=LHSSampler()):
547552
548553
"""
549554
uncertainties = determine_parameters(models, "uncertainties", union=union)
555+
556+
if not uncertainties:
557+
raise EMAError("you are trying to sample scenarios, but no uncertainties have been defined")
558+
550559
return sample_parameters(uncertainties, n_samples, sampler, Policy)
551560

552561

0 commit comments

Comments
 (0)