Expand Hypothesis and edge-case tests for elections, strategies, and methods#49
Draft
endolith wants to merge 3 commits into
Draft
Expand Hypothesis and edge-case tests for elections, strategies, and methods#49endolith wants to merge 3 commits into
endolith wants to merge 3 commits into
Conversation
…, methods - Elections: property tests for random_utilities, impartial_culture, and normal_electorate; spatial utilities bounded when distances spread; document NaN output when two candidates coincide for a voter. - Strategies: honest_rankings permutation and tie-order invariants; approval threshold strictness; vote_for_k approval counts with strict utilities; honest_normed_scores degenerate and stabilized property cases. - Condorcet: pairwise matrix rows partition voters; Condorcet winner beats all others pairwise. - Methods: Black agrees with Condorcet or Borda branch; SNTV n=1 vs FPTP with order tiebreak; ranked methods return valid IDs; utility_winner vs column sums; explicit ties for utility_winner and combined approval. Co-authored-by: endolith <endolith@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #49 +/- ##
=======================================
Coverage 96.31% 96.31%
=======================================
Files 19 19
Lines 489 489
=======================================
Hits 471 471
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:
|
…istake) Co-authored-by: endolith <endolith@gmail.com>
- Elections: extend random_utilities, impartial_culture, normal_electorate, and normed_dist_utilities in place; remove duplicate property tests. - Strategies: merge uniform utilities, indifferent scores, strict approval threshold, and strict vote_for_k counts into existing tests. - Methods: restore test_methods to shared tiebreaker/degeneracy tests only; move Black composition and SNTV-vs-FPTP checks to test_black and test_sntv. - Approval: add combined-approval balanced-ballot tie next to CAV examples. Condorcet pairwise matrix properties unchanged. Co-authored-by: endolith <endolith@gmail.com>
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.
Summary
Adds property-based and explicit edge-case tests so tie-breaking, degenerate ballots, and spatial corner cases are exercised beyond line coverage alone.
Elections (
test_elections.py)random_utilities, valid permutations forimpartial_culture, and finite outputs fornormal_electorate(with constraints so the correlation scaling stays real).normed_dist_utilities: when every voter has distinct nearest/farthest distances, utilities stay in[0, 1]with correct row min/max; when two candidates share the same coordinates, documents currentnanbehavior from0/0normalization.Strategies (
test_strategies.py)honest_rankings: ballots remain permutations; constant utilities tie-break toward higher candidate ids first (NumPyargsortbehavior).approval_optimal: all-equal utilities yield no approvals; every approval implies strictly above the row mean.vote_for_k: with strictly ordered utilities per row, each ballot has exactlykapprovals.honest_normed_scores: explicit all-equal case; property test perturbs rows slightly so min/max normalization is well-defined without heavyassumefiltering.Condorcet / pairwise (
test_condorcet.py)test_ranked_election_to_matrix(shape, diagonal, min/max bounds) unchanged in intent alongside new tests.i < j,M[i,j] + M[j,i] == n_voters.Methods (
test_methods.py)n=1andtiebreaker='order'agrees with FPTP with the same tiebreaker (includingNonewhen both are tied).Noneas appropriate;utility_winner(..., 'order')matchesargmaxof column sums.utility_winnerwith two-way total tie;combined_approvalwith symmetric+1/-1ballots.