Skip to main content

PsifosPoll is a python library for different voting methods

Project description

PsifosPoll: Library for Election Result Algorithms

PsifosPoll is a Python library developed by the electronic voting system Psifos team. For more information about our work, visit the Psifos Participa UChile instance page: Participa UChile.

Description

PsifosPoll is a Python library designed to contain different algorithms for calculating the result of an election.

Currently, the library includes the algorithm for preferential ranking voting, Single Transferable Vote (STV), in its Weighted Inclusive Gregory Method version with a droop quota.

Resources

Installation

You can install PsifosPoll using the pip package manager. Run the following command in your terminal:

$ pip install psifospoll

Usage Example

Here is a basic example of how to use PsifosPoll with STV:

from psifospoll import STVElection

def stvTally(seats, candidates_list, ballot_list):
    election = STVElection()
    election.runElection(seats, candidates_list, ballot_list)
    print(election.getRoundResumes())
    print(election.getTalliesResumes())
    print(election.getWinnersList())

# Voting example
# Three seats, five candidates and six ballots
l1 = [
    [1, 2, 3, 4, 5],
    [5, 4, 3, 2, 1],
    [2, 3, 4, 5, 1],
    [3, 4, 5, 1, 2],
    [4, 5, 1, 2, 3],
    [1, 2, 3, 4, 5],
]
cand = [1, 2, 3, 4, 5]
stvTally(3, cand, l1)
# In this example, STV runs for 3 rounds, and candidates 1, 3 and 4 are elected.

More Examples

You can find more examples of possible inputs for STV in the examples.py file of the library.

Contributions

We would love to receive contributions! If you want to make a Pull Request (PR), make sure the code used is formatted with the black library. You can do this by running the following command in the PsifosPoll directory:

black .

Contact

If you have any questions, feel free to contact us at participa@uchile.cl

Thank you for using PsifosPoll!

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

psifospoll-1.0.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

psifospoll-1.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file psifospoll-1.0.1.tar.gz.

File metadata

  • Download URL: psifospoll-1.0.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for psifospoll-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1fd31f321c9965610f2fc1dd281e131562f4a088b6e52a82d842e31ba8724aea
MD5 b46e48353d868781feca21e2b6fd3b4a
BLAKE2b-256 28febabb86f040659b91e94c48b673c7e8ff3222c58d9ed568ca90b5a5d930e7

See more details on using hashes here.

File details

Details for the file psifospoll-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: psifospoll-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for psifospoll-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a76b6eb705c37bfe856415f2aa365e51ced68454eede751cf8a6019640e033e
MD5 df10c9951bd6f7c4d18a84179343a202
BLAKE2b-256 5b75f1cca4f749e5e594192aff7b2f5a671b074cb8d68008a1c6acd61081abbd

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