Code Duplication    Length = 25-25 lines in 3 locations

tests/test_random_state.py 3 locations

@@ 154-178 (lines=25) @@
151
    assert abs(best_score0 - best_score1) < err
152
153
154
def test_random_state_2():
155
    """Test different results with different random states."""
156
    hyper0 = Hyperactive()
157
    hyper0.add_search(
158
        objective_function,
159
        search_space,
160
        n_iter=10,
161
        initialize={"random": 1},
162
        random_state=1,
163
    )
164
    hyper0.run()
165
166
    hyper1 = Hyperactive()
167
    hyper1.add_search(
168
        objective_function,
169
        search_space,
170
        n_iter=10,
171
        initialize={"random": 1},
172
        random_state=10,
173
    )
174
    hyper1.run()
175
176
    best_score0 = hyper0.best_score(objective_function)
177
    best_score1 = hyper1.best_score(objective_function)
178
179
    assert abs(best_score0 - best_score1) > err
180
181
@@ 126-150 (lines=25) @@
123
    assert abs(best_score0 - best_score1) < err
124
125
126
def test_random_state_1():
127
    """Test reproducibility with same random state (different value)."""
128
    hyper0 = Hyperactive()
129
    hyper0.add_search(
130
        objective_function,
131
        search_space,
132
        n_iter=10,
133
        initialize={"random": 1},
134
        random_state=10,
135
    )
136
    hyper0.run()
137
138
    hyper1 = Hyperactive()
139
    hyper1.add_search(
140
        objective_function,
141
        search_space,
142
        n_iter=10,
143
        initialize={"random": 1},
144
        random_state=10,
145
    )
146
    hyper1.run()
147
148
    best_score0 = hyper0.best_score(objective_function)
149
    best_score1 = hyper1.best_score(objective_function)
150
151
    assert abs(best_score0 - best_score1) < err
152
153
@@ 98-122 (lines=25) @@
95
    assert int(len(results) / n_jobs) != len(no_dup)
96
97
98
def test_random_state_0():
99
    """Test reproducibility with same random state."""
100
    hyper0 = Hyperactive()
101
    hyper0.add_search(
102
        objective_function,
103
        search_space,
104
        n_iter=10,
105
        initialize={"random": 1},
106
        random_state=1,
107
    )
108
    hyper0.run()
109
110
    hyper1 = Hyperactive()
111
    hyper1.add_search(
112
        objective_function,
113
        search_space,
114
        n_iter=10,
115
        initialize={"random": 1},
116
        random_state=1,
117
    )
118
    hyper1.run()
119
120
    best_score0 = hyper0.best_score(objective_function)
121
    best_score1 = hyper1.best_score(objective_function)
122
123
    assert abs(best_score0 - best_score1) < err
124
125