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 42c16b4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/utilities/MonteCarlo/Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,16 @@ def __call__(cls, params):

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

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

# setup data logging
if len(simParams.retentionPolicies) > 0:
Expand Down Expand Up @@ -921,4 +927,3 @@ def populateSeeds(simInstance, modifications):
if ".RNGSeed" in variable:
rngStatement = "simInstance." + variable + "=" + value
exec(rngStatement)

0 comments on commit 42c16b4

Please sign in to comment.