Add a test case where the No Award runoff changes the result - #485
Open
JonathanLennox wants to merge 2 commits into
Open
Add a test case where the No Award runoff changes the result#485JonathanLennox wants to merge 2 commits into
JonathanLennox wants to merge 2 commits into
Conversation
Five ballots in which Candidate A survives the instant-runoff count, but No Award is ranked above A on three of them, so the final runoff against No Award overturns the count. None of the existing cases fail if the runoff is dropped or miscounted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
offbyone
reviewed
Jul 30, 2026
| if cr.status == CandidateStatus.Elected | ||
| ) | ||
|
|
||
| def votes(round, candidate) -> float: |
Contributor
There was a problem hiding this comment.
This type doesn't sit right with me; I know the underlying library works in floating point, but in practice these are integers. Seeing an int compared with equality to a float down on lines 250-251 is twitch-inducing.
I realize that's more an aesthetic judgement than a technical one, because a similar comparison happens up-file, but nevertheless, I'd prefer that the clamping to integer happen in this method instead of implicitly in the checks down below.
The tally is floating point in pyrankvote, but these are whole votes; convert in the helper rather than leaving the assertions to compare an int against a float. The helpers' `round` parameter is renamed so it doesn't shadow the builtin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Author
|
I pushed a change to return int from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
TestEdgeCases.test_no_award_wins_the_runoff, covering the minimal ballot set in which the final runoff against No Award overturns the instant-runoff count:B, C and No Award tie for last with one first preference each and are eliminated together; no ballot has a surviving preference to transfer, so A fills the only seat with 2 votes. No Award then beats A 3–2 in the runoff.
None of the existing cases fail if the runoff is dropped or miscounted; this one does.
Verified: 7 passed in
test_constitution_2023.py,ruff checkandruff format --checkclean. The test needs no database — it callshugo_votingdirectly with pyrankvote objects.🤖 Generated with Claude Code