Skip to main content

Python Vote Core (py-vote-core)

py-vote-core implements various electoral methods, providing the results calculated off a provided set of ballots and options.

Methods implemented

  • Single Winner Methods

    • Plurality (aka first-past-the-post or fptp)
    • Instant-Runoff Voting (aka IRV)
    • Schulze Method (aka Beatpath)
  • Multiple Winner Methods

    • Plurality at large (aka block voting)
    • Single Transferable Vote (aka STV)
    • Schulze STV
  • Ordering Methods

    • Schulze Proportional Representation
    • Schulze Nonproportional Representation

Basic Usage

Schulze method example::

>>> from py3votecore.schulze_method import SchulzeMethod
>>> from py3votecore.condorcet import CondorcetHelper
>>> ballots = [
...   { "count":3, "ballot":[["A"], ["C"], ["D"], ["B"]] },
...   { "count":9, "ballot":[["B"], ["A"], ["C"], ["D"]] },
...   { "count":8, "ballot":[["C"], ["D"], ["A"], ["B"]] },
...   { "count":5, "ballot":[["D"], ["A"], ["B"], ["C"]] },
...   { "count":5, "ballot":[["D"], ["B"], ["C"], ["A"]] }
... ]
>>> SchulzeMethod(ballots, ballot_notation = CondorcetHelper.BALLOT_NOTATION_GROUPING).as_dict()
{'actions': [{'edges': {('A', 'B')}},
  {'edges': {('A', 'C')}},
  {'nodes': {'A'}},
  {'edges': {('B', 'C')}},
  {'nodes': {'B', 'D'}}],
 'candidates': {'A', 'B', 'C', 'D'},
 'pairs': {('A', 'B'): 16,
  ('A', 'C'): 17,
  ('A', 'D'): 12,
  ('B', 'A'): 14,
  ('B', 'C'): 19,
  ('B', 'D'): 9,
  ('C', 'A'): 13,
  ('C', 'B'): 11,
  ('C', 'D'): 20,
  ('D', 'A'): 18,
  ('D', 'B'): 21,
  ('D', 'C'): 10},
 'strong_pairs': {('A', 'B'): 16,
  ('A', 'C'): 17,
  ('B', 'C'): 19,
  ('C', 'D'): 20,
  ('D', 'A'): 18,
  ('D', 'B'): 21},
 'winner': 'C'}

This library would not be possible without the contributions of its various authors. Please see the CONTRIBUTORS file for a list of developers who have contributed to this software.

Metadata

Release files for py-vote-core 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-vote-core 2.0.0
File Size Uploaded Provenance Actions
py_vote_core-2.0.0.tar.gz 95.3 kB Without provenance Details for py_vote_core-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-vote-core 2.0.0
File Interpreter ABI Platform Actions
py_vote_core-2.0.0-py3-none-any.whl Python 3 none any Details for py_vote_core-2.0.0-py3-none-any.whl

Total release size: 112.3 kB

Release files / py_vote_core-2.0.0.tar.gz

Download URL py_vote_core-2.0.0.tar.gz
Size 95.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a7981614d78ef09c4448806088fdfe9dc10b6f1aec4592ed5cde3d7bfded668b
BLAKE2b-256 checksum
How to use checksums
83cc64d00107eec5097d809b5117ddac038ec823f96241594ab3428ee9b9ec0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / py_vote_core-2.0.0-py3-none-any.whl

Download URL py_vote_core-2.0.0-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e8c1a51eee85f952cbf8c5278bad283f475928033ef01c94d96649b1ab79937
BLAKE2b-256 checksum
How to use checksums
e68782b249cdfd052553828d43ee303bc4f79a4a5b82427da8d112d6c82f19b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for py-vote-core 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page