Skip to content

Issue #20: bimodal winner distributions, 3-2-1, partisan primaries, Score/STAR ranges#50

Open
endolith wants to merge 7 commits into
masterfrom
cursor/issue-20-winner-distributions-4616
Open

Issue #20: bimodal winner distributions, 3-2-1, partisan primaries, Score/STAR ranges#50
endolith wants to merge 7 commits into
masterfrom
cursor/issue-20-winner-distributions-4616

Conversation

@endolith

Copy link
Copy Markdown
Owner

This PR implements the simulations and mechanisms discussed in issue #20.

Library additions

  • bimodal_electorate (elsim.elections): two voter clusters and matching candidate pools at ±separation on the first axis (documented indexing convention for left/right voters and candidates).
  • three_two_one (elsim.methods): 3-2-1 voting with ballots encoded as 0 = Bad, 1 = OK, 2 = Good (party-specific semifinalist rules omitted as optional for simulations).
  • honest_321_ratings (elsim.strategies): per-voter tertiles → Good/OK/Bad.
  • honest_normed_scores(utilities, max_score=5, *, min_score=0): keyword-only min_score; keeps positional max_score for backward compatibility; rows with no utility spread map to min_score.
  • Partisan helpers (elsim.methods): restricted plurality nominees, pairwise majority between finalists, open vs closed partisan flows, top-two runoff with a subset electorate in the pairwise round.

Examples (same style as distributions_by_method.py)

  • examples/bimodal_winner_distributions.py: 5k+5k voters, two clusters of candidates, dispersion 0.5, reduced-turnout primaries (~3.8k each side) and runoff (~8.5k voters). Methods include FPTP, contingent runoff, IRV, Score/STAR (0–5), Black, open/closed partisan primaries, 3-2-1, approval (mean threshold and vote-for-half), reference histograms.
  • examples/score_star_range_comparison.py: same unimodal spatial setup as existing 1D plots; compares Score vs STAR for ranges 0–5, 0–10, 1–10, five-grade (0–4), 13- and 15-point scales.
  • examples/bimodal_approval_strategy_comparison.py: optimal approval vs vote-for-half vs vote-for-one on the bimodal electorate.

Tests

  • bimodal_electorate shape/means; three_two_one edge cases; extended invalid tiebreaker coverage.

All tests pass (pytest tests/).

Open in Web Open in Cursor 

@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.23%. Comparing base (3249c6c) to head (8af7090).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   96.37%   97.23%   +0.86%     
==========================================
  Files          17       19       +2     
  Lines         496      652     +156     
==========================================
+ Hits          478      634     +156     
  Misses         18       18              
Flag Coverage Δ
no-numba 96.77% <100.00%> (+1.01%) ⬆️
numba 90.95% <100.00%> (+2.84%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dependabot Bot and others added 7 commits May 29, 2026 00:53
Bumps [https://github.com/astral-sh/ruff-pre-commit](https://github.com/astral-sh/ruff-pre-commit) from v0.15.14 to 0.15.15.
- [Release notes](https://github.com/astral-sh/ruff-pre-commit/releases)
- [Commits](astral-sh/ruff-pre-commit@v0.15.14...v0.15.15)

---
updated-dependencies:
- dependency-name: https://github.com/astral-sh/ruff-pre-commit
  dependency-version: 0.15.15
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
…hub.com/astral-sh/ruff-pre-commit-0.15.15

Bump https://github.com/astral-sh/ruff-pre-commit from v0.15.14 to 0.15.15
Bumps [https://github.com/astral-sh/ruff-pre-commit](https://github.com/astral-sh/ruff-pre-commit) from v0.15.15 to 0.15.16.
- [Release notes](https://github.com/astral-sh/ruff-pre-commit/releases)
- [Commits](astral-sh/ruff-pre-commit@v0.15.15...v0.15.16)

---
updated-dependencies:
- dependency-name: https://github.com/astral-sh/ruff-pre-commit
  dependency-version: 0.15.16
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
…hub.com/astral-sh/ruff-pre-commit-0.15.16

Bump https://github.com/astral-sh/ruff-pre-commit from v0.15.15 to 0.15.16
…ries

- bimodal_electorate() for two spatial clusters; partisan primary/runoff helpers
- three_two_one() with Good/OK/Bad ballots; honest_321_ratings() strategy
- honest_normed_scores(max_score, *, min_score) with tied-utility rows at min
- Examples: bimodal winner histograms (turnout variants), Score vs STAR ranges,
  bimodal approval strategy comparison
- Tests for bimodal electorate, 3-2-1, and invalid tiebreakers

Co-authored-by: endolith <endolith@gmail.com>
- Exercise nominee_restricted_plurality, pairwise_majority, open/closed
  primaries, top_two_runoff_reduced_turnout (including sntv edge cases)
- Cover three_two_one pairwise branches and 2D validation
- Cover honest_321_ratings and honest_normed_scores invalid min/max range

Co-authored-by: endolith <endolith@gmail.com>
Co-authored-by: endolith <endolith@gmail.com>
@cursor cursor Bot force-pushed the cursor/issue-20-winner-distributions-4616 branch from f24f6fb to 8af7090 Compare June 12, 2026 17:22
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.

2 participants