Skip to content

Commit

Permalink
Added a list of nonexistent candidates that get zeroed out.
Browse files Browse the repository at this point in the history
  • Loading branch information
j3camero committed Oct 9, 2015
1 parent eb42995 commit e3a1a16
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions riding_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
'62': 'NU',
}

nonexistent_candidates = {
'59014': ['gpc'],
'10004': ['gpc'],
}

def WhichParty(s):
"""If the given string contains a party name, return its abbreviation."""
for abbreviation, long_name in party_long_names.items():
Expand Down Expand Up @@ -215,6 +220,9 @@ def KeyWithHighestValue(d, forbidden_keys=[]):
# Upgrade the projections for ridings that have local polling data.
projections = riding_poll_model.projections_by_riding_number.get(
riding_number, projections)
for party in nonexistent_candidates.get(riding_number, []):
projections[party] = 0
projections = NormalizeDictVector(projections)
ordered_projections = [projections.get(p, 0) for p in party_order]
projected_winner = KeyWithHighestValue(projections)
runner_up = KeyWithHighestValue(projections, [projected_winner])
Expand Down

0 comments on commit e3a1a16

Please sign in to comment.