test_best_results_0()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
import pytest
2
import random
3
import numpy as np
4
5
from ._parametrize import optimizers
6
7
8
def objective_function(para):
9
    return -(para["x1"] + para["x1"])
10
11
12
search_space1 = {
13
    "x1": np.array([1]),
14
    "x2": np.arange(-10, 10, 1),
15
}
16
17
search_space2 = {
18
    "x1": np.arange(-10, 10, 1),
19
    "x2": np.array([1]),
20
}
21
22
23
objective_para = (
24
    "search_space",
25
    [
26
        (search_space1),
27
        (search_space2),
28
    ],
29
)
30
31
32
@pytest.mark.parametrize(*objective_para)
33
@pytest.mark.parametrize(*optimizers)
34
def test_best_results_0(Optimizer, search_space):
35
    opt = Optimizer(search_space)
36
    opt.search(objective_function, n_iter=30)
37