diff --git a/README.md b/README.md index 2f8aaef9..2bf01135 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ chunks = { indicates that the districting plan creates 16 pieces of county. ## Documentation -Read the documentation [here](https://mggg.github.io/plan-evaluation-tools/). To +Read the documentation [here](https://mggg.github.io/evaltools/). To create documentation after adding features, please ensure you're following the [Google Python style guide](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings), then run `sh docs.sh`. Pushing to the repository will modify the documentation automatically. diff --git a/evaltools/scoring/partisan.py b/evaltools/scoring/partisan.py index 277cd414..e8184663 100644 --- a/evaltools/scoring/partisan.py +++ b/evaltools/scoring/partisan.py @@ -1,16 +1,16 @@ -from functools import cache +from functools import lru_cache from gerrychain import Partition import numpy as np from typing import Iterable, Tuple from .score_types import * -@cache +@lru_cache(maxsize=None) def _election_results(part: Partition, election_cols: Tuple[str], party: str): return np.array([ np.array([part[e].percent(party, d) for d in sorted(part.parts.keys()) if d != -1]) for e in election_cols ]) -@cache +@lru_cache(maxsize=None) def _election_stability(part: Partition, election_cols: Tuple[str], party: str): return (_election_results(part, election_cols, party) > 0.5).sum(axis=0) @@ -88,4 +88,4 @@ def _eguia_election(part: Partition, e: str, party: str, county_part: Partition, def _eguia(part: Partition, election_cols: Iterable[str], party: str, county_part: Partition, totpop_col: str, mean: bool = False) -> ScoreValue: result = {e: _eguia_election(part, e, party, county_part, totpop_col) for e in election_cols} - return float(np.mean(list(result.values()))) if mean else result \ No newline at end of file + return float(np.mean(list(result.values()))) if mean else result diff --git a/setup.py b/setup.py index 8b825671..1fad5bd2 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ requirements = [ "pandas", "scipy", "networkx", "geopandas", "shapely", "matplotlib", "gerrychain", "sortedcontainers", "gurobipy", "jsonlines", "opencv-python", - "imageio", "us", "pydantic", "censusdata", "seaborn" + "imageio", "us", "pydantic", "censusdata", "seaborn", "maup" ] setup(