Skip to content
Merged
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
13 changes: 8 additions & 5 deletions bayes_opt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class ScreenLogger(_Tracker):

_default_cell_size = 9
_default_precision = 4

_colour_new_max = Fore.MAGENTA
_colour_regular_message = Fore.RESET
_colour_reset = Fore.RESET

def __init__(self, verbose=2, is_constrained=False):
self._verbose = verbose
self._is_constrained = is_constrained
Expand Down Expand Up @@ -136,7 +139,7 @@ def _format_key(self, key):
return s[:self._default_cell_size - 3] + "..."
return s

def _step(self, instance, colour=Fore.BLACK):
def _step(self, instance, colour=_colour_regular_message):
"""Log a step.

Parameters
Expand All @@ -145,7 +148,7 @@ def _step(self, instance, colour=Fore.BLACK):
The instance associated with the event.

colour :
(Default value = Fore.BLACK)
(Default value = _colour_regular_message, equivalent to Fore.RESET)

Returns
-------
Expand All @@ -163,7 +166,7 @@ def _step(self, instance, colour=Fore.BLACK):
for key in instance.space.keys:
cells.append(self._format_number(res["params"][key]))

return "| " + " | ".join([colour + cells[i] for i in range(len(cells))]) + " |"
return "| " + " | ".join([colour + cells[i] + self._colour_reset for i in range(len(cells))]) + " |"

def _header(self, instance):
"""Print the header of the log.
Expand Down Expand Up @@ -231,7 +234,7 @@ def update(self, event, instance):
if self._verbose == 1 and not is_new_max:
line = ""
else:
colour = Fore.MAGENTA if is_new_max else Fore.BLACK
colour = self._colour_new_max if is_new_max else self._colour_regular_message
line = self._step(instance, colour=colour) + "\n"
elif event == Events.OPTIMIZATION_END:
line = "=" * self._header_length + "\n"
Expand Down
2 changes: 1 addition & 1 deletion bayes_opt/target_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def register(self, params, target, constraint_value=None):
self.n_duplicate_points = self.n_duplicate_points + 1

print(Fore.RED + f'Data point {x} is not unique. {self.n_duplicate_points}'
' duplicates registered. Continuing ...')
' duplicates registered. Continuing ...' + Fore.RESET)
else:
raise NotUniqueError(f'Data point {x} is not unique. You can set'
' "allow_duplicate_points=True" to avoid this error')
Expand Down