def example_partition(): df = gp.read_file(os.path.join(TEST_DATA_PATH, "mo_cleaned_vtds.shp")) with open(os.path.join(TEST_DATA_PATH, "MO_graph.json")) as f: graph_json = json.load(f) graph = networkx.readwrite.json_graph.adjacency_graph(graph_json) assignment = get_assignment_dict(df, "GEOID10", "CD") add_data_to_graph( df, graph, ['PR_DV08', 'PR_RV08', 'POP100', 'ALAND10', 'COUNTYFP10'], id_col='GEOID10') updaters = { **votes_updaters(['PR_DV08', 'PR_RV08'], election_name='08'), 'population': Tally('POP100', alias='population'), 'counties': county_splits('counties', 'COUNTYFP10'), 'cut_edges': cut_edges, 'cut_edges_by_part': cut_edges_by_part } return Partition(graph, assignment, updaters)
def example_partition(): df = gp.read_file("./testData/mo_cleaned_vtds.shp") with open("./testData/MO_graph.json") as f: graph_json = json.load(f) graph = networkx.readwrite.json_graph.adjacency_graph(graph_json) assignment = get_assignment_dict(df, "GEOID10", "CD") add_data_to_graph( df, graph, ['PR_DV08', 'PR_RV08', 'POP100', 'ALAND10', 'COUNTYFP10'], id_col='GEOID10') updaters = { **votes_updaters(['PR_DV08', 'PR_RV08'], election_name='08'), 'population': Tally('POP100', alias='population'), 'areas': Tally('ALAND10', alias='areas'), 'counties': county_splits('counties', 'COUNTYFP10'), 'perimeters': perimeters, 'exterior_boundaries': exterior_boundaries, 'boundary_nodes': boundary_nodes, 'polsby_popper': polsby_popper, 'cut_edges': cut_edges, 'cut_edges_by_part': cut_edges_by_part } return Partition(graph, assignment, updaters)