Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion bayes_opt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _format_number(self, x: float) -> str:
result = ""
width = self._default_cell_size
# Keep negative sign, exponent, and as many decimal places as possible
if "-" in s:
if x < 0:
result += "-"
width -= 1
s = s[1:]
Expand Down
4 changes: 4 additions & 0 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def test_format_number():
assert len(formatted) == logger._default_cell_size
assert formatted == "1.234e+13"

sci_float = 1.11111111e-5
formatted = logger._format_number(sci_float)
assert formatted == "1.111e-05"

# Test negative scientific notation truncation
sci_float = -12345678901234.5678901234
formatted = logger._format_number(sci_float)
Expand Down