Passed
Push — master ( 4ef66c...afb360 )
by Simon
03:52
created

tests.test_optimizers._base_test._base_test()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
import numpy as np
2
3
4
def get_score(pos_new):
5
    return -(pos_new[0] * pos_new[0])
6
7
8
search_space = [np.arange(-100, 100, 1)]
9
10
11
def _base_test(
12
    opt_class, n_iter, get_score=get_score, search_space=search_space, opt_para={},
13
):
14
    opt = opt_class(search_space, **opt_para)
15
    opt.search(get_score, n_iter=n_iter)
16
17