コード例 #1
0
    def test_uses_graph_geometries_by_default(self, geodataframe):
        mock_plot = MagicMock()
        gp.GeoDataFrame.plot = mock_plot

        graph = Graph.from_geodataframe(geodataframe)
        partition = Partition(graph=graph,
                              assignment={node: 0
                                          for node in graph})
        partition.plot()
        assert mock_plot.call_count == 1
コード例 #2
0
    Election("PRES16", {
        "Dem": "G16PREDCLI",
        "Rep": "G16PRERTRU"
    })
]

mo_updaters = {
    "population": Tally("POP10", alias="population"),
    "cut_edges": cut_edges
}
election_updaters = {election.name: election for election in elections}
mo_updaters.update(election_updaters)

sen_part = Partition(graph, assignment="SLDUST", updaters=mo_updaters)
sen_part["PRES16"].efficiency_gap()
sen_part.plot(cmap="tab20")
plt.show()  # show the state senate map
cong_part = Partition(graph, assignment="SLDLST", updaters=mo_updaters)

# load parts (aka district maps) from gerrychain
# "assignment" = mapping of node IDs to district IDs
sen_parts = np.load(
    "/Users/hopecj/projects/gerryspam/MO/res/MO_state_senate_100000_0.05_parts.p"
)

# load up saved parts to find smallest EG from saved maps
# starting seed for "small EG" plans
sen_parts = np.load(
    "/Users/hopecj/projects/gerryspam/MO/res_0527/MO_state_senate_1000_0.05_parts.p"
)
sen_parts.keys()