@@ 161-179 (lines=19) @@ | ||
158 | ) |
|
159 | ||
160 | ||
161 | def test_search_space_6(): |
|
162 | def objective_function(opt): |
|
163 | score = -opt["x1"] * opt["x1"] |
|
164 | return score |
|
165 | ||
166 | search_space = { |
|
167 | "x1": list(range(0, 100, 1)), |
|
168 | "list1": [[1, 1, 1], [1, 2, 1], [1, 1, 2]], |
|
169 | } |
|
170 | ||
171 | hyper = Hyperactive() |
|
172 | hyper.add_search( |
|
173 | objective_function, search_space, n_iter=15, |
|
174 | ) |
|
175 | hyper.run() |
|
176 | ||
177 | assert isinstance(hyper.results(objective_function), pd.DataFrame) |
|
178 | assert ( |
|
179 | hyper.best_para(objective_function)["list1"] in search_space["list1"] |
|
180 | ) |
|
181 | ||
@@ 45-62 (lines=18) @@ | ||
42 | assert hyper.best_para(objective_function)["x1"] in search_space["x1"] |
|
43 | ||
44 | ||
45 | def test_search_space_2(): |
|
46 | def objective_function(opt): |
|
47 | score = -opt["x1"] * opt["x1"] |
|
48 | return score |
|
49 | ||
50 | search_space = { |
|
51 | "x1": list(range(0, 100, 1)), |
|
52 | "str1": ["0", "1", "2"], |
|
53 | } |
|
54 | ||
55 | hyper = Hyperactive() |
|
56 | hyper.add_search( |
|
57 | objective_function, search_space, n_iter=15, |
|
58 | ) |
|
59 | hyper.run() |
|
60 | ||
61 | assert isinstance(hyper.results(objective_function), pd.DataFrame) |
|
62 | assert hyper.best_para(objective_function)["str1"] in search_space["str1"] |
|
63 | ||
64 | ||
65 | def test_search_space_3(): |