runoff: reuse IRV Numba tally helpers for head-to-head round#46
runoff: reuse IRV Numba tally helpers for head-to-head round#46endolith wants to merge 1 commit into
Conversation
Second-round contingent vote compares two finalists by whoever appears first on each ballot. That matches advancing each voter's rank index past all non-finalists then tallying at that rank—the same _inc_rank_idx and _tally_at_rank_idx path IRV uses. Co-authored-by: endolith <endolith@gmail.com>
PR Summary
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46 +/- ##
==========================================
+ Coverage 96.31% 96.33% +0.01%
==========================================
Files 19 19
Lines 489 491 +2
==========================================
+ Hits 471 473 +2
Misses 18 18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #3.
What changed
The contingent-vote / top-two runoff second round used a Python loop with
list.indexper ballot. That round is equivalent to “instant runoff among only the two finalists”: skip every other candidate on each ballot, then take first preference among{finalist_0, finalist_1}. That is exactly what_inc_rank_idx+_tally_at_rank_idxdo—the same Numba path IRV uses.Details
eliminated_candsas all candidate IDs except the two finalists._inc_rank_idxonly when that set is non-empty (same Numba empty-set guard as IRV)._tally_at_rank_idxand read counts at the two finalist indices.All 215 tests pass locally.