def test_data_tally_works_as_an_updater(three_by_three_grid): assignment = random_assignment(three_by_three_grid, 4) data = {node: random.randint(1, 100) for node in three_by_three_grid.nodes} parts = tuple(set(assignment.values())) updaters = {"tally": DataTally(data, alias="tally")} partition = Partition(three_by_three_grid, assignment, updaters) flip = {random.choice(list(partition.graph.nodes)): random.choice(parts)} new_partition = partition.flip(flip) assert new_partition["tally"]
def attach_random_data(graph, columns): for node in graph.nodes: for col in columns: graph.nodes[node][col] = random.randint(1, 1000)