Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions HPOlib/Plotting/doAllPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _plot_trace(pkl_list, name_list, save="", cut=sys.maxint, log=False):
plotTrace.main(pkl_list, name_list, save=save, log=log, cut=cut)
os.chdir(cur_dir)
sys.stdout.write("passed\n")
except Exception, e:
except Exception as e:
sys.stderr.write(format_traceback(sys.exc_info()))
sys.stderr.write("failed: %s %s" % (sys.exc_info()[0], e))

Expand All @@ -63,7 +63,7 @@ def _trace_with_std_per_eval(pkl_list, name_list, save="",
optimum=0, save=save, log=log, cut=cut)
os.chdir(cur_dir)
sys.stdout.write("passed\n")
except Exception, e:
except Exception as e:
sys.stderr.write(format_traceback(sys.exc_info()))
sys.stderr.write("failed: %s %s" % (sys.exc_info()[0], e))

Expand All @@ -81,7 +81,7 @@ def _trace_with_std_per_time(pkl_list, name_list, save="",
optimum=0, save=save, log=log, cut=cut)
os.chdir(cur_dir)
sys.stdout.write("passed\n")
except Exception, e:
except Exception as e:
sys.stderr.write(format_traceback(sys.exc_info()))
sys.stderr.write("failed: %s %s" % (sys.exc_info()[0], e))

Expand All @@ -99,7 +99,7 @@ def _optimizer_overhead(pkl_list, name_list, save="",
log=log, save=save, cut=cut)
os.chdir(cur_dir)
sys.stdout.write("passed\n")
except Exception, e:
except Exception as e:
sys.stderr.write(format_traceback(sys.exc_info()))
sys.stderr.write("failed: %s %s" % (sys.exc_info()[0], e))

Expand All @@ -115,7 +115,7 @@ def _box_whisker(pkl_list, name_list, save="", cut=sys.maxint, log=False):
plotBoxWhisker.main(pkl_list, name_list, save=save, cut=cut)
os.chdir(cur_dir)
sys.stdout.write("passed\n")
except Exception, e:
except Exception as e:
sys.stderr.write(format_traceback(sys.exc_info()))
sys.stderr.write("failed: %s %s" % (sys.exc_info()[0], e))

Expand All @@ -131,7 +131,7 @@ def _generate_tex_table(pkl_list, name_list, save="", cut=sys.maxint,
generateTexTable.main(pkl_list, name_list, save, cut)
os.chdir(cur_dir)
sys.stdout.write("passed\n")
except Exception, e:
except Exception as e:
sys.stderr.write(format_traceback(sys.exc_info()))
sys.stderr.write("failed: %s %s" % (sys.exc_info()[0], e))

Expand Down Expand Up @@ -159,7 +159,7 @@ def _statistics(pkl_list, name_list, save="", cut=sys.maxint, log=False):
print (out)
os.chdir(cur_dir)
sys.stdout.write("passed\n")
except Exception, e:
except Exception as e:
sys.stderr.write(format_traceback(sys.exc_info()))
sys.stderr.write("failed: %s %s" % (sys.exc_info()[0], e))

Expand Down Expand Up @@ -236,7 +236,7 @@ def main():
ret = _generate_tex_table(pkl_list=pkl_list, name_list=name_list,
save=tmp_save, log=log, cut=args.cut)
if ret is not None:
print ret
print(ret)


# We can always plot this
Expand Down
2 changes: 1 addition & 1 deletion HPOlib/Plotting/plotBoxWhisker.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def plot_box_whisker(best_trials, name_list, title="", save="", y_min=0,
min_y = min(best_trials[i])
if max(best_trials[i]) > max_y:
max_y = max(best_trials[i])
print medians
print(medians)

# Plot xticks
xticks(range(1, len(name_list)+1), name_list)
Expand Down
6 changes: 3 additions & 3 deletions HPOlib/Plotting/plotBranin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def plot_contour(trial_list, name_list, save="", title=""):

# Get values
for opt in range(len(name_list)):
print name_list[opt], "has", len(trial_list[opt]['trials']), "samples"
print(name_list[opt], "has", len(trial_list[opt]['trials']), "samples")
m = markers.next()
c = colors.next()
x = np.zeros(len(trial_list[opt]["trials"]))
Expand Down Expand Up @@ -126,8 +126,8 @@ def main():
args, unknown = parser.parse_known_args()

if len(unknown) % 2 != 0:
print "Wrong number of arguments", len(args)
print prog
print("Wrong number of arguments", len(args))
print(prog)
sys.exit(1)

pkl_list, name_list = plotUtil.get_pkl_and_name_list(unknown)
Expand Down
6 changes: 3 additions & 3 deletions HPOlib/Plotting/plotOptimizerOverhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def main(pkl_list, name_list, autofill, title="", log=False, save="",
pass
else:
# Yes ... trouble
print "Help"
print trials["endtime"][time_idx]
print cv_endtime[i]
print("Help")
print(trials["endtime"][time_idx])
print(cv_endtime[i])
time_idx += 1
# everything ...
else:
Expand Down
2 changes: 1 addition & 1 deletion HPOlib/Plotting/plotParam.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def main(pkl_list, name_list, param, save="", title="", jitter=0):
(param, "\n".join([p[1:] for p in param_set])))
sys.exit(1)
else:
print "Found %s values for %s" % (str(len(value_list)), param)
print("Found %s values for %s" % (str(len(value_list)), param))

plot_params(value_list=value_list, result_list=result_list, name=param, save=save, title=title,
jitter=jitter)
Expand Down
4 changes: 2 additions & 2 deletions HPOlib/Plotting/plotTrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def plot_optimization_trace(trial_list, name_list, optimum=0, title="", log=Fals
# This might not do what we actually want; Ideally it would only take the
# ones that where actually run according to instance_order
for i in range(len(name_list)):
print cut, len(trial_list[i])
print(cut, len(trial_list[i]))
num_plotted_trials = np.min([cut, len(trial_list[i])])
print num_plotted_trials
print(num_plotted_trials)
x = range(num_plotted_trials)
y = np.zeros((num_plotted_trials))
line = np.zeros((num_plotted_trials))
Expand Down
4 changes: 2 additions & 2 deletions HPOlib/Plotting/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _get_best_trial(filename, cut=None):
best_idx = 0
if cut is None:
cut = len(trials['trials'])
print filename, "#Trials", len(trials['trials'])
print(filename, "#Trials", len(trials['trials']))
for i, trial in enumerate(trials['trials'][:cut]):
result = trial['result']
if result < current_best:
Expand All @@ -52,7 +52,7 @@ def _get_best_trial(filename, cut=None):
raise Exception("%s does not contain any results" % filename)
return current_best, best_idx
except Exception as e:
print "Problem with ", filename, e
print("Problem with ", filename, e)
sys.stdout.flush()
return None, None

Expand Down
4 changes: 2 additions & 2 deletions HPOlib/benchmark_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def lda_on_grid(kappa, tau, s, ret_time=False):
config_tree[config[0]][config[1]][config[2]][0] = config[3]
config_tree[config[0]][config[1]][config[2]][1] = config[4]

print kappa, tau, s
print(kappa, tau, s)
if ret_time:
return config_tree[kappa_values[kappa]][tau_values[tau]][s_values[s]][1]
else:
Expand Down Expand Up @@ -1908,7 +1908,7 @@ def svm_on_grid(c, alpha, epsilon, ret_time=False):
config_tree[config[0]][config[1]][config[2]][0] = config[3]
config_tree[config[0]][config[1]][config[2]][1] = config[4]

print c, alpha, epsilon
print(c, alpha, epsilon)
if ret_time:
return config_tree[c_values[c]][alpha_values[alpha]][epsilon_values[epsilon]][1]
else:
Expand Down
16 changes: 8 additions & 8 deletions HPOlib/format_converter/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ def smac_to_spearmint_helper(space, save=""):


def smac_to_tpe_helper(space, save=""):
print "This is not yet implemented"
raise NotImplementedError("smac_to_tpe_helper is not implemented")


def spearmint_to_smac_helper(space, save=""):
print "This is not yet implemented"
raise NotImplementedError("smac_to_smac_helper is not implemented")


def spearmint_to_tpe_helper(space, save=""):
print "This is not yet implemented"
raise NotImplementedError("spearmint_to_tpe_helper is not implemented")


def tpe_to_spearmint_helper(space, save=""):
try:
import hyperopt
except ImportError:
print "Cannot find hyperopt. To use this converter, modify $PYTHONPATH to contain a hyperopt installation"
print("Cannot find hyperopt. To use this converter, modify $PYTHONPATH to contain a hyperopt installation")

# First convert to smac
tmp = tpe_to_smac.convert_tpe_to_smac_from_file(space)
Expand All @@ -73,7 +73,7 @@ def tpe_to_smac_helper(space, save=""):
try:
import hyperopt
except ImportError:
print "Cannot find hyperopt. To use this converter, modify $PYTHONPATH to contain a hyperopt installation"
print("Cannot find hyperopt. To use this converter, modify $PYTHONPATH to contain a hyperopt installation")
return tpe_to_smac.convert_tpe_to_smac_from_file(space)


Expand Down Expand Up @@ -101,7 +101,7 @@ def main():

space = os.path.abspath(args.space)
if not os.path.isfile(space):
print "%s is not a valid path" % space
print("%s is not a valid path" % space)
sys.exit(1)

# Unifying strings
Expand All @@ -113,7 +113,7 @@ def main():
args.conv_to == "TPE"

if args.conv_to == args.conv_from:
print "Converting from %s to %s makes no sense" % (args.conv_to, args.conv_from)
print("Converting from %s to %s makes no sense" % (args.conv_to, args.conv_from))

# This is like a switch statement
options = {'SMAC': {'SPEARMINT': smac_to_spearmint_helper,
Expand All @@ -129,7 +129,7 @@ def main():
fh.write(new_space)
fh.close()
else:
print new_space
print(new_space)

if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions HPOlib/format_converter/tpe_to_smac.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def convert_tpe_to_smac_from_file(filename):
#noinspection PyBroadException
try:
space = imp.load_source(space_name, filename)
except Exception, e:
except Exception as e:
print("Could not find\n%s\n\tin\n%s\n\trelative to\n%s"
% (space_name, filename, os.getcwd()))
import traceback
print traceback.format_exc()
print(traceback.format_exc())
sys.exit(1)

search_space = space.space
Expand Down
2 changes: 1 addition & 1 deletion HPOlib/runsolver_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def main():
del experiment

logger.info(return_string)
print return_string
print(return_string)
return return_string


Expand Down
2 changes: 1 addition & 1 deletion HPOlib/wrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def main():
output_file = os.path.join(optimizer_dir_in_experiment, optimizer + ".out")
fh = open(output_file, "a")
cmd = shlex.split(cmd)
print cmd
print(cmd)

# Use a flag which is set to true as soon as all children are
# supposed to be killed
Expand Down
15 changes: 6 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_find_packages():
def download_source(download_url, md5, save_as):
try:
urllib.urlretrieve(download_url, filename=save_as)
except Exception, e:
except Exception as e:
sys.stdout.write("Error downloading %s: %s\n" % (download_url, e))
return False
md5_new = hashlib.md5(open(save_as).read()).hexdigest()
Expand All @@ -54,7 +54,7 @@ def extract_source(fn_name, extract_as):
try:
tfile = tarfile.open(fn_name)
tfile.extractall(extract_as)
except Exception, e:
except Exception as e:
sys.stdout.write("Error occurred during extraction: %s\n" % e)
return False
return True
Expand All @@ -69,7 +69,7 @@ def copy_folder(new_dir, old_dir):
sys.stderr.write("[shutil.ERROR] Could not copy folder from %s to %s\n" % (old_dir, new_dir))
sys.stderr.write("%s\n" % e.message)
return False
except Exception, e:
except Exception as e:
sys.stderr.write("[ERROR] Could not copy folder from %s to %s\n" % (old_dir, new_dir))
sys.stderr.write("%s\n" % e.message)
return False
Expand All @@ -83,7 +83,7 @@ def make_dir(new_dir):
else:
sys.stdout.write("[INFO] %s is already a directory, we use it for our installation\n" %
new_dir)
except Exception, e:
except Exception as e:
sys.stdout.write("[ERROR] Something (%s) went wrong, please create %s and try again\n" %
(e.message, new_dir))

Expand Down Expand Up @@ -114,7 +114,7 @@ def _build(self, build_dir):
os.chdir(build_dir)
try:
subprocess.check_call("make")
except subprocess.CalledProcessError, e:
except subprocess.CalledProcessError as e:
sys.stdout.write("Error while building runsolver: %s\n" % e)
os.chdir(cur_pwd)
return False
Expand Down Expand Up @@ -143,9 +143,6 @@ def run(self):
here_we_are = os.getcwd()
runsolver_tar_name = "runsolver-3.3.4.tar.bz2"
runsolver_name = "runsolver-3.3.4"
if sys.version_info < (2, 7, 0) or sys.version_info >= (2, 8, 0):
sys.stderr.write("HPOlib requires Python 2.7.0\n")
sys.exit(-1)

downloaded, extracted, built = (False, False, False)
runsolver_needs_to_be_installed = False
Expand Down Expand Up @@ -174,7 +171,7 @@ def run(self):
call = "sed -i 's|gnu/asm/unistd_$(WSIZE).h|gnu/asm/unistd_$(WSIZE).h /usr/include/i386-linux-gnu/asm/unistd_$(WSIZE).h|' runsolver/src/Makefile"
try:
subprocess.check_call(call, shell=True)
except subprocess.CalledProcessError, e:
except subprocess.CalledProcessError as e:
sys.stdout.write("Replacing did not work: %s\n" % e)
md5_new = hashlib.md5(open("runsolver/src/Makefile").read()).hexdigest()
runsolver_md5 = "4870722e47a6f74d5167376d371f1730"
Expand Down