Skip to content

Commit

Permalink
MAINT rework if/else construct, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeurer committed Oct 12, 2016
1 parent b19e1c1 commit 9eb9bf3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions smac/facade/smac_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,23 @@ def __init__(self,
scenario.cs)

# initialize tae_runner
if tae_runner is not None and callable(tae_runner):
tae_runner = ExecuteTAFunc(ta=tae_runner,
stats=self.stats,
run_obj=scenario.run_obj,
runhistory=runhistory,
par_factor=scenario.par_factor)
elif tae_runner is None:
# First case, if tae_runner is None, the target algorithm is a call
# string in the scenario file
if tae_runner is None:
tae_runner = ExecuteTARunOld(ta=scenario.ta,
stats=self.stats,
run_obj=scenario.run_obj,
runhistory=runhistory,
par_factor=scenario.par_factor)
# Second case, the tae_runner is a function to be optimized
elif callable(tae_runner):
tae_runner = ExecuteTAFunc(ta=tae_runner,
stats=self.stats,
run_obj=scenario.run_obj,
runhistory=runhistory,
par_factor=scenario.par_factor)
# Third case, if it is an ExecuteTaRun we can simply use the
# instance. Otherwise, the next check raises an exception
elif not isinstance(tae_runner, ExecuteTARun):
raise TypeError("Argument 'tae_runner' is %s, but must be "
"either a callable or an instance of "
Expand Down

0 comments on commit 9eb9bf3

Please sign in to comment.