Skip to content

Commit

Permalink
Merge pull request #40 from washingtonpost/release/0.0.5
Browse files Browse the repository at this point in the history
release: 0.0.5
  • Loading branch information
chriszs authored Nov 8, 2022
2 parents 8c2a4d7 + f6bdfc2 commit 2dd511b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.0.5] - 2022-11-04

- [#39] Remove locality from race ID, add it back to subunit ID

## [0.0.4] - 2022-11-04

- [#36] Remove county ID from precinct ID
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
LONG_DESCRIPTION = f.read()

# The full version, including alpha/beta/rc tags
RELEASE = '0.0.4'
RELEASE = '0.0.5'
# The short X.Y version
VERSION = '.'.join(RELEASE.split('.')[:2])

Expand Down
3 changes: 3 additions & 0 deletions src/elexclarity/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def convert(
data,
vote_completion_mode=vote_completion_mode,
office_id=office_id,
omit_locality_from_race_id=kwargs.get(
"omit_locality_from_race_id", True
),
**kwargs
)

Expand Down
2 changes: 1 addition & 1 deletion src/elexclarity/formatters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_choice_id(cls, name):
return slugify(name, separator="_")

def get_precinct_id(self, name, county_id=None):
return slugify(name, separator="-")
return "_".join(filter(None,[county_id, slugify(name, separator='-')]))

def get_county_id(self, name):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/elexclarity/formatters/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def format_race(
election_type,
office
]
if level == "precinct":
if level == "precinct" and not kwargs.get("omit_locality_from_race_id"):
id_parts.append(county_id)
race_id = "_".join(id_parts)

Expand Down
8 changes: 4 additions & 4 deletions tests/formatters/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def test_georgia_precinct_formatting_basic(atkinson_precincts, ga_county_mapping
assert counts["jo_jorgensen_lib"] == 30

# Pearson City precinct
pearson = results["2020-11-03_GA_G_P_13003"]["subunits"]["pearson-city"]
pearson = results["2020-11-03_GA_G_P_13003"]["subunits"]["13003_pearson-city"]
assert pearson["precinctsReportingPct"] == 100
assert pearson["expectedVotes"] == 564
assert pearson["counts"]["donald_j_trump_i_rep"] == 229
assert pearson["counts"]["joseph_r_biden_dem"] == 329
assert pearson["counts"]["jo_jorgensen_lib"] == 6

# Willacoochee precinct
willacoochee = results["2020-11-03_GA_G_P_13003"]["subunits"]["willacoochee"]
willacoochee = results["2020-11-03_GA_G_P_13003"]["subunits"]["13003_willacoochee"]
assert willacoochee["precinctsReportingPct"] == 100
assert willacoochee["expectedVotes"] == 522
assert willacoochee["counts"]["donald_j_trump_i_rep"] == 342
Expand All @@ -45,12 +45,12 @@ def test_georgia_precinct_formatting_vote_types_completion_mode(atkinson_precinc
)

# Pearson City precinct
pearson = results["2020-11-03_GA_G_P_13003"]["subunits"]["pearson-city"]
pearson = results["2020-11-03_GA_G_P_13003"]["subunits"]["13003_pearson-city"]
assert pearson["precinctsReportingPct"] == 100
assert pearson["expectedVotes"] == 564

# Willacoochee precinct
willacoochee = results["2020-11-03_GA_G_P_13003"]["subunits"]["willacoochee"]
willacoochee = results["2020-11-03_GA_G_P_13003"]["subunits"]["13003_willacoochee"]
assert willacoochee["precinctsReportingPct"] == 0
assert willacoochee.get("expectedVotes") is None

Expand Down

0 comments on commit 2dd511b

Please sign in to comment.