@@ -246,8 +246,16 @@ def test_neighbors_hamming():
246
246
(3 , 4 , 'string_1' ),
247
247
]
248
248
249
+ # test the neighbors
249
250
__test_neighbors (test_config , expected_neighbors , "Hamming" )
250
251
252
+ # test the random neighbor function
253
+ neighbors = simple_searchspace .get_neighbors (test_config , "Hamming" )
254
+ for i in range (10 ):
255
+ random_neighbor = simple_searchspace .get_random_neighbor (test_config , "Hamming" )
256
+ assert random_neighbor in neighbors
257
+ assert random_neighbor != test_config
258
+
251
259
252
260
def test_neighbors_strictlyadjacent ():
253
261
"""Test whether the strictly adjacent neighbors are as expected."""
@@ -259,8 +267,16 @@ def test_neighbors_strictlyadjacent():
259
267
(1.5 , 5.5 , 'string_2' ),
260
268
]
261
269
270
+ # test the neighbors
262
271
__test_neighbors (test_config , expected_neighbors , "strictly-adjacent" )
263
272
273
+ # test the random neighbor function
274
+ neighbors = simple_searchspace .get_neighbors (test_config , "strictly-adjacent" )
275
+ for i in range (10 ):
276
+ random_neighbor = simple_searchspace .get_random_neighbor (test_config , "strictly-adjacent" )
277
+ assert random_neighbor in neighbors
278
+ assert random_neighbor != test_config
279
+
264
280
265
281
def test_neighbors_adjacent ():
266
282
"""Test whether the adjacent neighbors are as expected."""
@@ -272,8 +288,16 @@ def test_neighbors_adjacent():
272
288
(1.5 , 5.5 , 'string_2' ),
273
289
]
274
290
291
+ # test the neighbors
275
292
__test_neighbors (test_config , expected_neighbors , "adjacent" )
276
293
294
+ # test the random neighbor function
295
+ neighbors = simple_searchspace .get_neighbors (test_config , "adjacent" )
296
+ for i in range (10 ):
297
+ random_neighbor = simple_searchspace .get_random_neighbor (test_config , "adjacent" )
298
+ assert random_neighbor in neighbors
299
+ assert random_neighbor != test_config
300
+
277
301
278
302
def test_neighbors_fictious ():
279
303
"""Test whether the neighbors are as expected for a fictious parameter configuration (i.e. not existing in the search space due to restrictions)."""
0 commit comments