Passed
Push — master ( 502a6e...660aa4 )
by Simon
04:50 queued 14s
created

parabola_function()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
import pytest
6
import numpy as np
7
8
9
from gradient_free_optimizers import BayesianOptimizer
10
11
12
def parabola_function(para):
13
    loss = para["x"] * para["x"] + para["y"] * para["y"]
14
    return -loss
15
16
17
search_space = {
18
    "x": np.arange(-1, 1, 1),
19
    "y": np.arange(-1, 1, 1),
20
}
21
22
23
def test_replacement_0():
24
    opt = BayesianOptimizer(search_space, replacement=True)
25
    opt.search(parabola_function, n_iter=15)
26
27
    with pytest.raises(ValueError):
28
        opt = BayesianOptimizer(search_space, replacement=False)
29
        opt.search(parabola_function, n_iter=15)
30