County-District & COI Splitting

You can calculate county-district splitting metrics, as well as community of interest (COI) splitting metrics.

County & District Splitting

To calculate the county & district splitting scores for a plan:

def calc_splitting_metrics(CxD: list[list[float]]) -> dict:

where “CxD” is are county totals (columns) by district (rows), i.e., each row represents a district, and each value in the row represents the number of people in that county in that district.

Examples can be found in the “counties” section of the profiles in the testdata/CD116 directory.

This returns a simple dictionary of results:

result: dict = {"county": county, "district": district}

These measures are described in Measuring County & District Splitting. As the post describes, these measures are based on Moon Duchin’s raw square root entropy split score. Note: The example in the figure shows districts as columns and counties as rows, the opposite of how they are represented in the code.

def split_score(split: list[float]) -> float:

Community of Interest Splitting

To calculate the COI splitting for a set of communities:

def calc_coi_splitting(communities: list[dict[str, list[float]]]) -> dict:

where “communities” is a list of communities of interest (COIs), each of which is a dictionary with a “name” and “splits” entry, the latter being a list of floats in the range [0-1] representing how a COI is fractionated across districts.

This returns a dictionary of results:

results: dict = {"byCOI": by_coi}

where the entry for each COI is of the form:

{"name": coi["name"], "effectiveSplits": es, "uncertainty": u}

These two measures are described in COI Splitting.

The metrics can also be called individually:

def uncertainty_of_membership(splits: list[float]) -> float:
def effective_splits(splits: list[float]) -> float:

where “splits” is, again, a list of floats in the range [0-1] representing how a COI is fractionated across districts.