Skip to content

Commit

Permalink
Merge pull request #276 from PSLmodels/new-cds
Browse files Browse the repository at this point in the history
Check area name validity using number of 118th Congressional districts
  • Loading branch information
martinholmer authored Nov 4, 2024
2 parents 04e5039 + 0a38f0c commit d5601b0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tmd/areas/create_area_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def valid_area(area: str):
# Census on which Congressional districts are based:
# : cd_census_year = 2010 implies districts are for the 117th Congress
# : cd_census_year = 2020 implies districts are for the 118th Congress
cd_census_year = 2010
cd_census_year = 2020
# data in the state_info dictionary is taken from the following document:
# 2020 Census Apportionment Results, April 26, 2021,
# Table C1. Number of Seats in
Expand Down Expand Up @@ -124,6 +124,13 @@ def valid_area(area: str):
total[2020] += seats[2020]
assert total[2010] == 435
assert total[2020] == 435
compare_new_vs_old = False
if compare_new_vs_old:
text = "state,2010cds,2020cds"
for state, seats in state_info.items():
if seats[2020] != seats[2010]:
print(f"{text}= {state} {seats[2010]:2d} {seats[2020]:2d}")
sys.exit(1)
# conduct series of validity checks on specified area string
# ... check that specified area string has expected length
len_area_str = len(area)
Expand Down

0 comments on commit d5601b0

Please sign in to comment.