MCPcopy Index your code
hub / github.com/bayesian-optimization/BayesianOptimization / test_step

Function test_step

tests/test_logger.py:147–169  ·  view source on GitHub ↗

Test the _print_step method.

()

Source from the content-addressed store, hash-verified

145
146
147def test_step():
148 """Test the _print_step method."""
149 optimizer = BayesianOptimization(target_func, PBOUNDS, random_state=1)
150
151 logger = ScreenLogger()
152
153 # Register a point so we have something to log
154 optimizer.register(params={"p1": 1.5, "p2": 2.5}, target=4.0)
155
156 # Test default color
157 step_str = logger._print_step(
158 optimizer._space.keys, optimizer._space.res()[-1], optimizer._space.params_config
159 )
160 assert "|" in step_str
161 assert "1" in step_str # iteration
162 assert "4.0" in step_str # target value
163
164 # Test with custom color
165 custom_color = Fore.RED
166 step_str_colored = logger._print_step(
167 optimizer._space.keys, optimizer._space.res()[-1], optimizer._space.params_config, color=custom_color
168 )
169 assert custom_color in step_str_colored
170
171
172def test_print_header():

Callers

nothing calls this directly

Calls 5

registerMethod · 0.95
_print_stepMethod · 0.95
ScreenLoggerClass · 0.90
resMethod · 0.45

Tested by

no test coverage detected