Skip to main content

python-vote-core implements various electoral methods, providing the results calculated off a provided set of ballots and options. This fork implements only Python3 compatibility!

Python3

This fork implements Python3 functionality by using 2to3 and then cherry-picking fixes from other people’s forks. This is certainly not a clean way to do so but 100% of the tests pass on Python3.

This fork exists solely to have a PyPI release under Python3.

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 pyvotecore.schulze_method import SchulzeMethod
>>> from pyvotecore.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'}

20110509.1 —

  • Fixing PyPi release

20110509.0 —

  • Initial PyPi release

License

Copyright (C) 2009, Brad Beattie

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.

Metadata

Release files for python3-vote-core 20170329.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 python3-vote-core 20170329.0
File Size Uploaded
python3-vote-core-20170329.0.tar.gz 35.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python3-vote-core 20170329.0
File Interpreter ABI Platform
python3_vote_core-20170329.0-py3-none-any.whl Python 3 none any Details

Total release size: 81.5 kB

Release files / python3-vote-core-20170329.0.tar.gz

Download URL python3-vote-core-20170329.0.tar.gz
Size 35.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a2566482ba5afba5bdafe7069578ccf146ed5ec12c2ef6a88eafeef35740b694
BLAKE2b-256 checksum
How to use checksums
91d58b85db9e827e21da4cb627c57ff1dfce59ffb2bb4cb9352e97b15b95d181
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python3_vote_core-20170329.0-py3-none-any.whl

Download URL python3_vote_core-20170329.0-py3-none-any.whl
Size 46.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb2b626f6a990a39528b94940601f37c4fcd59892cc0c0e9bb709a47d1e54c65
BLAKE2b-256 checksum
How to use checksums
2b0f98480dd67f63f33d3a423eb0b96d1a44f1d21028d09a9a37e1498773b47c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

20170329.0 This release

2 release files

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