Skip to content

Commit

Permalink
fix verbosity for progress-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBlanke committed May 22, 2023
1 parent 8c5ad83 commit 9afa1fe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
34 changes: 18 additions & 16 deletions hyperactive/optimizers/hyper_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,28 +126,30 @@ def search(self, nth_process, p_bar):
False,
)
for nth_iter in range(self.n_iter):
p_bar.set_description(
"["
+ str(nth_process)
+ "] "
+ str(self.objective_function.__name__)
+ " ("
+ self.optimizer_class.name
+ ")",
)
if p_bar:
p_bar.set_description(
"["
+ str(nth_process)
+ "] "
+ str(self.objective_function.__name__)
+ " ("
+ self.optimizer_class.name
+ ")",
)

self.gfo_optimizer.search_step(nth_iter)
if self.gfo_optimizer.stop.check():
break

p_bar.set_postfix(
best_score=str(gfo_wrapper_model.optimizer.score_best),
best_pos=str(gfo_wrapper_model.optimizer.pos_best),
best_iter=str(gfo_wrapper_model.optimizer.p_bar._best_since_iter),
)
if p_bar:
p_bar.set_postfix(
best_score=str(gfo_wrapper_model.optimizer.score_best),
best_pos=str(gfo_wrapper_model.optimizer.pos_best),
best_iter=str(gfo_wrapper_model.optimizer.p_bar._best_since_iter),
)

p_bar.update(1)
p_bar.refresh()
p_bar.update(1)
p_bar.refresh()

self.gfo_optimizer.finish_search()

Expand Down
22 changes: 13 additions & 9 deletions hyperactive/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@


def _process_(nth_process, optimizer):
p_bar = tqdm(
position=nth_process,
total=optimizer.n_iter,
ascii=" ─",
colour="Yellow",
)
if "progress_bar" in optimizer.verbosity:
p_bar = tqdm(
position=nth_process,
total=optimizer.n_iter,
ascii=" ─",
colour="Yellow",
)
else:
p_bar = None

optimizer.search(nth_process, p_bar)

p_bar.colour = "GREEN"
p_bar.refresh()
p_bar.close()
if p_bar:
p_bar.colour = "GREEN"
p_bar.refresh()
p_bar.close()

return {
"nth_process": nth_process,
Expand Down

0 comments on commit 9afa1fe

Please sign in to comment.