|
@@ 95-118 (lines=24) @@
|
| 92 |
|
assert abs(np.sum(n_last_scores0) - np.sum(n_last_scores1)) > err |
| 93 |
|
|
| 94 |
|
|
| 95 |
|
def test_random_state_direct(): |
| 96 |
|
opt0 = DirectAlgorithm( |
| 97 |
|
search_space, initialize={"random": n_random}, random_state=1 |
| 98 |
|
) |
| 99 |
|
opt0.search( |
| 100 |
|
objective_function, |
| 101 |
|
n_iter=n_iter, |
| 102 |
|
) |
| 103 |
|
|
| 104 |
|
opt1 = DirectAlgorithm( |
| 105 |
|
search_space, initialize={"random": n_random}, random_state=10 |
| 106 |
|
) |
| 107 |
|
opt1.search( |
| 108 |
|
objective_function, |
| 109 |
|
n_iter=n_iter, |
| 110 |
|
) |
| 111 |
|
|
| 112 |
|
print("\n opt0.search_data \n", opt0.search_data) |
| 113 |
|
print("\n opt1.search_data \n", opt1.search_data) |
| 114 |
|
|
| 115 |
|
n_last_scores0 = list(opt0.search_data["score"].values)[-n_last:] |
| 116 |
|
n_last_scores1 = list(opt1.search_data["score"].values)[-n_last:] |
| 117 |
|
|
| 118 |
|
assert abs(np.sum(n_last_scores0) - np.sum(n_last_scores1)) < err |
| 119 |
|
|
| 120 |
|
|
| 121 |
|
@pytest.mark.parametrize(*optimizers) |
|
@@ 72-92 (lines=21) @@
|
| 69 |
|
assert abs(np.sum(n_last_scores0) - np.sum(n_last_scores1)) < err |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@pytest.mark.parametrize(*optimizers) |
| 73 |
|
def test_random_state_2(Optimizer): |
| 74 |
|
opt0 = Optimizer(search_space, initialize={"random": n_random}, random_state=1) |
| 75 |
|
opt0.search( |
| 76 |
|
objective_function, |
| 77 |
|
n_iter=n_iter, |
| 78 |
|
) |
| 79 |
|
|
| 80 |
|
opt1 = Optimizer(search_space, initialize={"random": n_random}, random_state=10) |
| 81 |
|
opt1.search( |
| 82 |
|
objective_function, |
| 83 |
|
n_iter=n_iter, |
| 84 |
|
) |
| 85 |
|
|
| 86 |
|
print("\n opt0.search_data \n", opt0.search_data) |
| 87 |
|
print("\n opt1.search_data \n", opt1.search_data) |
| 88 |
|
|
| 89 |
|
n_last_scores0 = list(opt0.search_data["score"].values)[-n_last:] |
| 90 |
|
n_last_scores1 = list(opt1.search_data["score"].values)[-n_last:] |
| 91 |
|
|
| 92 |
|
assert abs(np.sum(n_last_scores0) - np.sum(n_last_scores1)) > err |
| 93 |
|
|
| 94 |
|
|
| 95 |
|
def test_random_state_direct(): |
|
@@ 29-49 (lines=21) @@
|
| 26 |
|
n_last = n_iter - n_random |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
@pytest.mark.parametrize(*optimizers) |
| 30 |
|
def test_random_state_0(Optimizer): |
| 31 |
|
opt0 = Optimizer(search_space, initialize={"random": n_random}, random_state=1) |
| 32 |
|
opt0.search( |
| 33 |
|
objective_function, |
| 34 |
|
n_iter=n_iter, |
| 35 |
|
) |
| 36 |
|
|
| 37 |
|
opt1 = Optimizer(search_space, initialize={"random": n_random}, random_state=1) |
| 38 |
|
opt1.search( |
| 39 |
|
objective_function, |
| 40 |
|
n_iter=n_iter, |
| 41 |
|
) |
| 42 |
|
|
| 43 |
|
print("\n opt0.search_data \n", opt0.search_data) |
| 44 |
|
print("\n opt1.search_data \n", opt1.search_data) |
| 45 |
|
|
| 46 |
|
n_last_scores0 = list(opt0.search_data["score"].values)[-n_last:] |
| 47 |
|
n_last_scores1 = list(opt1.search_data["score"].values)[-n_last:] |
| 48 |
|
|
| 49 |
|
assert abs(np.sum(n_last_scores0) - np.sum(n_last_scores1)) < err |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@pytest.mark.parametrize(*optimizers) |