Skip to main content

An implementation of various election methods, most notably the Schulze Method and Schulze STV.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_vote_core-2.0.0.tar.gz (95.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_vote_core-2.0.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file py_vote_core-2.0.0.tar.gz.

File metadata

  • Download URL: py_vote_core-2.0.0.tar.gz
  • Upload date:
  • Size: 95.3 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for py_vote_core-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a7981614d78ef09c4448806088fdfe9dc10b6f1aec4592ed5cde3d7bfded668b
MD5 9a85764cafac5fad5c195af268fb0bee
BLAKE2b-256 83cc64d00107eec5097d809b5117ddac038ec823f96241594ab3428ee9b9ec0d

See more details on using hashes here.

File details

Details for the file py_vote_core-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_vote_core-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for py_vote_core-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e8c1a51eee85f952cbf8c5278bad283f475928033ef01c94d96649b1ab79937
MD5 5a695db1552ef0479bec25459be744cd
BLAKE2b-256 e68782b249cdfd052553828d43ee303bc4f79a4a5b82427da8d112d6c82f19b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page