Extract stateless IRV tabulation helpers - #61
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Reviewer's GuideExtracts IRV tabulation logic into stateless module-level helpers while preserving the existing Irv API via static aliases and adds focused regression tests for the helpers and keep semantics. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider normalizing the
eliminate_candidateAPI so it either always accepts a candidate ID or always requiresCandidateWithCount, rather than silently returning the input when given the wrong type, to make misuse easier to detect. - In
least_candidate, you might want to document or enforce thatkeepis a set-like collection for efficient membership checks, since callers could currently pass slower container types without realizing the cost.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider normalizing the `eliminate_candidate` API so it either always accepts a candidate ID or always requires `CandidateWithCount`, rather than silently returning the input when given the wrong type, to make misuse easier to detect.
- In `least_candidate`, you might want to document or enforce that `keep` is a set-like collection for efficient membership checks, since callers could currently pass slower container types without realizing the cost.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary
Irvmethod API through static aliaseskeep={}default withNoneStack
Depends on #60. Retarget this PR to
mainafter its parent merges.Validation
uv run python -m pytest(45 passed)trunk checkSummary by Sourcery
Extract stateless IRV tabulation helpers into module-level functions while preserving the existing Irv method API via static aliases.
Enhancements:
Nonedefault instead of a mutable set for the keep parameter.Tests: