| Total Complexity | 1 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |