Skip to content

Commit

Permalink
Merge pull request #156 from kiudee/fix_empty_data
Browse files Browse the repository at this point in the history
Fix error at start when no data has been collected yet
  • Loading branch information
kiudee committed Aug 14, 2021
2 parents f22a8ae + bd37f8c commit 87487bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
45 changes: 19 additions & 26 deletions tune/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,32 +350,25 @@ def local( # noqa: C901
while True:
root_logger.info("Starting iteration {}".format(iteration))

# Print/plot results so far:
result_object = create_result(Xi=X, yi=y, space=opt.space, models=[opt.gp])
result_every_n = settings.get("result_every", result_every)
if (
result_every_n > 0
and iteration % result_every_n == 0
and opt.gp.chain_ is not None
):
print_results(
optimizer=opt,
result_object=result_object,
parameter_names=list(param_ranges.keys()),
confidence=settings.get("confidence", confidence),
)
plot_every_n = settings.get("plot_every", plot_every)
if (
plot_every_n > 0
and iteration % plot_every_n == 0
and opt.gp.chain_ is not None
):
plot_results(
optimizer=opt,
result_object=result_object,
plot_path=settings.get("plot_path", plot_path),
parameter_names=list(param_ranges.keys()),
)
# If a model has been fit, print/plot results so far:
if len(y) > 0 and opt.gp.chain_ is not None:
result_object = create_result(Xi=X, yi=y, space=opt.space, models=[opt.gp])
result_every_n = settings.get("result_every", result_every)
if result_every_n > 0 and iteration % result_every_n == 0:
print_results(
optimizer=opt,
result_object=result_object,
parameter_names=list(param_ranges.keys()),
confidence=settings.get("confidence", confidence),
)
plot_every_n = settings.get("plot_every", plot_every)
if plot_every_n > 0 and iteration % plot_every_n == 0:
plot_results(
optimizer=opt,
result_object=result_object,
plot_path=settings.get("plot_path", plot_path),
parameter_names=list(param_ranges.keys()),
)

# Ask optimizer for next point:
point = opt.ask()
Expand Down
2 changes: 1 addition & 1 deletion tune/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def initialize_optimizer(
"valid. Reinitializing now."
)

if reinitialize:
if reinitialize and len(X) > 0:
logger.info(
f"Importing {len(X)} existing datapoints. " f"This could take a while..."
)
Expand Down

0 comments on commit 87487bb

Please sign in to comment.