Skip to content

Output formatting error for positive numbers in scientific notation with long mantissas and negative exponents #589

@LiemuR

Description

@LiemuR

Describe the bug
When outputting positive numbers in scientific notation with a long mantissa and negative exponent, the leading digit of the number is incorrectly replaced with a minus sign.
For example:​​
The positive number 1.11111111e-5 is incorrectly formatted as -.111e-05. This can be misleading because while the latter is a valid float representation in Python, it represents a completely different (and negative) value.

To Reproduce

from bayes_opt import BayesianOptimization

optimizer = BayesianOptimization(f=lambda x: x, pbounds={"x": (-1, 1)})
optimizer.probe({"x": 1.11111111e-5})
optimizer.maximize(init_points=0, n_iter=0)

Expected behavior
The leading digit of the number should not be replaced with a minus sign.

Screenshots
Result of running code snippet:
Image

Environment

  • OS: Windows
  • python Version 3.13.3
  • numpy Version 2.2.6
  • scipy Version 1.15.2
  • bayesian-optimization Version 3.1.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions