Skip to content

Split voting methods into package modules - #58

Merged
fsargent merged 2 commits into
mainfrom
refactor/methods-package
Jul 17, 2026
Merged

Split voting methods into package modules#58
fsargent merged 2 commits into
mainfrom
refactor/methods-package

Conversation

@fsargent

@fsargent fsargent commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • replace the monolithic vse_sim.methods module with a methods package
  • place each public voting method in its own module
  • preserve existing from vse_sim.methods import ... imports through package re-exports

Stack

Depends on #57. Retarget this PR to main after #57 merges.

Validation

  • uv run python -m pytest (44 passed)
  • trunk check

Summary by Sourcery

Split the monolithic voting methods module into a dedicated methods package while preserving the existing public API.

Enhancements:

  • Introduce individual modules for each voting method (e.g., IRV, IRV Prime, V321, Schulze, Ranked Pairs, Mav/Mj, Score/SRV, IRNR, Plurality, Borda, Bullety Approval) under a new methods package.
  • Add a package initializer that re-exports voting methods and helpers to maintain compatibility with existing vse_sim.methods imports.
  • Remove the old single methods.py module in favor of the new package structure.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sourcery-ai

sourcery-ai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors the monolithic vse_sim.methods module into a proper package, moving each voting method and helper into its own module while preserving the existing public API via package-level re-exports.

File-Level Changes

Change Details Files
Introduce dedicated modules for each voting method and helper function and wire them together via a methods package.
  • Move IRV implementation into a new Irv class module, keeping strategy and ballot helpers intact
  • Extract MAV and Majority Judgment logic into separate Mav and Mj modules, including shared toVote helper
  • Split out Borda-style ranked methods and shared fillPrefOrder/fillCands helpers into a standalone module
  • Add modules for IRNR, IRV Prime, 3-2-1 (V321), Score/Score Runoff (Srv), Schulze, Ranked Pairs (Rp), Plurality, and BulletyApprovalWith, each encapsulating its respective voting logic and strategy helpers
  • Create methods package init that re-exports all public voting classes and helpers to maintain from vse_sim.methods import ... compatibility
  • Remove the old monolithic methods.py in favor of the new package structure
src/vse_sim/methods/irv.py
src/vse_sim/methods/mav.py
src/vse_sim/methods/v321.py
src/vse_sim/methods/schulze.py
src/vse_sim/methods/irv_prime.py
src/vse_sim/methods/score.py
src/vse_sim/methods/borda.py
src/vse_sim/methods/irnr.py
src/vse_sim/methods/mj.py
src/vse_sim/methods/srv.py
src/vse_sim/methods/bullety_approval.py
src/vse_sim/methods/__init__.py
src/vse_sim/methods/plurality.py
src/vse_sim/methods/ranked_pairs.py
src/vse_sim/methods.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d767f0d6-f78d-4eca-8cb1-2f3e889e4080

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/methods-package

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
@fsargent
fsargent changed the base branch from fix-irv-results-contract to main July 17, 2026 22:20

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@fsargent
fsargent merged commit be45002 into main Jul 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant