Skip to main content

Python based election methods, includes python-vote-core and python-graph-core.

Project description

python-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 pyvotecore.schulze_method import SchulzeMethod
>>> 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 = "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.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

python-vote-full-1.0.tar.gz (52.5 kB view details)

Uploaded Source

File details

Details for the file python-vote-full-1.0.tar.gz.

File metadata

File hashes

Hashes for python-vote-full-1.0.tar.gz
Algorithm Hash digest
SHA256 00dc1c4b4d1f216acfdfb46bfca5b752cd32b9c6a55215a49a04b337fb23d70b
MD5 0496946be9328288b5d2a0b73104771e
BLAKE2b-256 aa7ea6bcb9b75d26daef8b76944d619c8d017d8283086ade000b114a8321bf6d

See more details on using hashes here.

Supported by

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