Repository navigation
VoteKit 3.5.0 expands the kinds of election data the library can represent and makes stochastic and fractionally weighted elections more reliable. It also adds new tools for combining and searching profiles, improves mentions performance, and gives STV animations configurable timing.
Highlights
String and integer candidates
Candidates may now be strings, integers, or a mixture of both across ballots, profiles, election methods, ballot generators, plots, graphs, matrices, and CSV serialization. Integer and string labels remain distinct, so 1 and "1" are separate candidates. Candidate validation and warnings cover labels whose displayed forms could collide. (PR #370)
Fuzzy rank-profile search
The new search_profile_for_rank_pattern utility finds ballots using partial or flexible ranking patterns. Queries can combine ordered candidates, exact tied positions, alternative matches, and maximum distances between candidate pairs or clones. Unranked candidates can optionally be treated as tied at the end of a ballot. (PR #373)
Reproducible stochastic APIs
Stochastic election methods, transfers, ballot generators, and sampling utilities now consistently accept rng_seed. Randomness is managed through local standard-library or NumPy generator objects, which makes repeated runs reproducible without overwriting shared global RNG state. (PR #375)
Exact arithmetic for STV-family elections
RankBallot and RankProfile now preserve fractions.Fraction weights. STV, IRV, and SequentialRCV accept exact=True to retain rational arithmetic through tallies, thresholds, tiebreak scores, election states, profile replay, and fractional transfers. The existing float path remains the default for compatibility and performance. (PR #377)
Added
search_profile_for_rank_patternsearchesRankProfiledata for ordered ranking patterns, exact tied positions, flexible alternatives, nearby candidate pairs or clones, and optionally unranked candidates. (PR #373)sum_profilescombines multiple rank profiles or multiple score profiles while reconciling their candidates, ranking lengths, weights, and voter sets. (PR #369)PreferenceInterval.from_dirichlet(..., sort_strengths_descending=True)assigns sampled support strengths in descending order of the supplied candidates. (PR #371)sort_candidates_pseudo_lexicographicallyprovides canonical numeric and ASCII ordering for mixed integer and string candidate sets. (PR #370)STVAnimationnow acceptsdelay_multandanimation_durationto control pauses and animation step duration. (PR #362)
Changed
RankBallotrankings may use bare candidates for singleton positions. For example,ranking=["A", "B"]is equivalent toranking=[{"A"}, {"B"}]; iterables still represent tied positions. (PR #368)
Fixed
Upgrade notes
- Exact arithmetic is opt-in; no change is required to retain existing float behavior.
- Fast NumPy-backed election implementations remain float-based.
- Fractionally weighted profiles are not yet supported by
PreferenceProfile.to_csv. ScoreBallotweights remain float-based; fraction preservation currently applies to rank ballots and the STV-family exact path.- The v2 CSV format preserves integer candidate types and remains able to read old-format files. A colon (
:) is now reserved and cannot appear in candidate names because it separates fields in the v2 encoding.
Full Changelog: v3.4.0...v3.5.0