Skip to content

Commit

Permalink
More robust history comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
donRumata03 committed Apr 16, 2024
1 parent dc7675b commit c7d26ba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/unit/utilities/random_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def test_random_seed_fully_determines_evolution_process():
""" Tests that random seed fully determines evolution process. """
# Setup graph search
target_graph = generate_labeled_graph('gnp', 5, node_labels=['X', 'Y'])
target_graph = generate_labeled_graph('tree', 4, node_labels=['X', 'Y'])

def launch_with_seed(seed):
set_random_seed(seed)
Expand All @@ -23,10 +23,9 @@ def launch_with_seed(seed):
return optimizer.history

def history_equals(history1, history2):
return all(
(history1.generations[i] == history2.generations[i])
for i in range(len(history1.generations))
)
def get_generation_ids(history):
return [[ind.graph.descriptive_id for ind in generation] for generation in history.generations]
return get_generation_ids(history1) == get_generation_ids(history2)

seed = 42
first_run = launch_with_seed(seed)
Expand Down

0 comments on commit c7d26ba

Please sign in to comment.