Skip to content

Commit

Permalink
Add check for dispersion variable that is callable
Browse files Browse the repository at this point in the history
  • Loading branch information
patkenneally committed Nov 5, 2024
1 parent 0392057 commit 3f8dc85
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/utilities/MonteCarlo/Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,15 @@ def __call__(cls, params):

# apply the dispersions and the random seeds
for variable, value in list(modifications.items()):
disperseStatement = "simInstance." + variable + "=" + value
disperseExpression = "simInstance." + variable
if eval("callable(" + disperseExpression + ")"):
expression = disperseExpression + "(" + value + ")"
else:
expression = disperseExpression + "=" + value

if simParams.verbose:
print("Executing parameter modification -> ", disperseStatement)
exec(disperseStatement)
print("Executing parameter modification -> ", expression)
exec(expression)

# setup data logging
if len(simParams.retentionPolicies) > 0:
Expand Down

0 comments on commit 3f8dc85

Please sign in to comment.