tests.test_obj_func_arg   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 20
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_argument_0() 0 22 1
1
"""Test module for objective function argument functionality."""
2
3
import numpy as np
4
5
from hyperactive import Hyperactive
6
7
search_space = {
8
    "x1": list(np.arange(0, 100, 1)),
9
}
10
11
12
def test_argument_0():
13
    """Test objective function arguments with pass_through parameter."""
14
15
    def objective_function(para):
16
        print("\npara.nth_iter", para.nth_iter)
17
        print("nth_iter_local", para.pass_through["nth_iter_local"])
18
19
        assert para.nth_iter == para.pass_through["nth_iter_local"]
20
21
        para.pass_through["nth_iter_local"] += 1
22
23
        return 0
24
25
    hyper = Hyperactive()
26
    hyper.add_search(
27
        objective_function,
28
        search_space,
29
        n_iter=100,
30
        pass_through={"nth_iter_local": 0},
31
        memory=False,
32
    )
33
    hyper.run()
34