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())
    print(election.getQuota())

# 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-2.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

psifospoll-2.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for psifospoll-2.1.0.tar.gz
Algorithm Hash digest
SHA256 e13fe5e4d207f07d7315c0abbafd751c001b4786c4c33b02d546a43ef0296d66
MD5 b298cda0574dba6ba542c076db8ef643
BLAKE2b-256 f9d831d12013c19c13ed626c01084e5f108b3e1ecbf907d0c03be5fbbf7f7d82

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for psifospoll-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc892eddc6511895f524cda6f9f191a00a12a5704057530b9b6e02bfc51088f9
MD5 7603a26e83c346e77418fb132f31fcce
BLAKE2b-256 eac916801b75a924300aae0f88dcb259c727a00c50ea9e0ca080f001d8fd5a87

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