(self)
| 5 | |
| 6 | class TestBayesOpt(unittest.TestCase): |
| 7 | def test_optimize(self): |
| 8 | # Bounded region of parameter space |
| 9 | pbounds = {'x': (2, 4), 'y': (-3, 3)} |
| 10 | |
| 11 | optimizer = BayesianOptimization( |
| 12 | f=black_box_function, |
| 13 | pbounds=pbounds, |
| 14 | random_state=1, |
| 15 | ) |
| 16 | |
| 17 | optimizer.maximize( |
| 18 | init_points=2, |
| 19 | n_iter=1, |
| 20 | ) |
| 21 | |
| 22 | self.assertAlmostEqual(-7, optimizer.max['target'], places=0) # compares using 0 decimal |
| 23 | |
| 24 | |
| 25 | def black_box_function(x, y): |
nothing calls this directly
no outgoing calls
no test coverage detected