Skip to content

Commit bc03387

Browse files
committed
Add check for dispersion variable that is callable
1 parent 0392057 commit bc03387

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/utilities/MonteCarlo/Controller.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,16 @@ def __call__(cls, params):
826826

827827
# apply the dispersions and the random seeds
828828
for variable, value in list(modifications.items()):
829-
disperseStatement = "simInstance." + variable + "=" + value
829+
expresion = "simInstance." + variable
830+
dispersionExpresion = None
831+
if eval("callable(" + expresion + ")"):
832+
dispersionExpresion = expresion + "(" + value + ")"
833+
else:
834+
dispersionExpresion = expresion + "=" + value
835+
830836
if simParams.verbose:
831-
print("Executing parameter modification -> ", disperseStatement)
832-
exec(disperseStatement)
837+
print("Executing parameter modification -> ", dispersionExpresion)
838+
exec(dispersionExpresion)
833839

834840
# setup data logging
835841
if len(simParams.retentionPolicies) > 0:

0 commit comments

Comments
 (0)