Code Duplication    Length = 19-20 lines in 3 locations

tests/test_search_spaces.py 3 locations

@@ 61-80 (lines=20) @@
58
    assert hyper.best_para(objective_function)["x1"] in search_space["x1"]
59
60
61
def test_search_space_2():
62
    """Test search space with numpy float range."""
63
64
    def objective_function(opt):
65
        score = -opt["x1"] * opt["x1"]
66
        return score
67
68
    search_space = {
69
        "x1": list(range(0, 100, 1)),
70
        "str1": ["0", "1", "2"],
71
    }
72
73
    hyper = Hyperactive()
74
    hyper.add_search(
75
        objective_function,
76
        search_space,
77
        n_iter=15,
78
    )
79
    hyper.run()
80
81
    assert isinstance(hyper.search_data(objective_function), pd.DataFrame)
82
    assert hyper.best_para(objective_function)["str1"] in search_space["str1"]
83
@@ 38-56 (lines=19) @@
35
    assert hyper.best_para(objective_function)["x1"] in search_space["x1"]
36
37
38
def test_search_space_1():
39
    """Test search space with float range."""
40
41
    def objective_function(opt):
42
        score = -opt["x1"] * opt["x1"]
43
        return score
44
45
    search_space = {
46
        "x1": list(np.arange(0, 0.003, 0.001)),
47
    }
48
49
    hyper = Hyperactive()
50
    hyper.add_search(
51
        objective_function,
52
        search_space,
53
        n_iter=15,
54
    )
55
    hyper.run()
56
57
    assert isinstance(hyper.search_data(objective_function), pd.DataFrame)
58
    assert hyper.best_para(objective_function)["x1"] in search_space["x1"]
59
@@ 15-33 (lines=19) @@
12
    pytest.skip("skip these tests for windows", allow_module_level=True)
13
14
15
def test_search_space_0():
16
    """Test search space with integer range."""
17
18
    def objective_function(opt):
19
        score = -opt["x1"] * opt["x1"]
20
        return score
21
22
    search_space = {
23
        "x1": list(range(0, 3, 1)),
24
    }
25
26
    hyper = Hyperactive()
27
    hyper.add_search(
28
        objective_function,
29
        search_space,
30
        n_iter=15,
31
    )
32
    hyper.run()
33
34
    assert isinstance(hyper.search_data(objective_function), pd.DataFrame)
35
    assert hyper.best_para(objective_function)["x1"] in search_space["x1"]
36