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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: psifospoll-1.0.2.tar.gz
  • Upload date:
  • Size: 6.0 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.2.tar.gz
Algorithm Hash digest
SHA256 cc543bfa9a2f386764ab97fe04ff2fc0f54046d11b192c0bf744ac8c097db25c
MD5 22ef4ceb3181514fbe712b9e5a4bc31b
BLAKE2b-256 2324d000f3be16e41ab28e2708f27fd9f3dcb56e5dc7028108cf0f2359d5466c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psifospoll-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c917e461ec34964a9e75de02d53e0df665b8dfdf7bf5c28564202f295392f3d9
MD5 abd66f328eeb8fdd8abb18b6b0af313d
BLAKE2b-256 be44bef4fa2ba178ee51aceb8cea3bb040b34b162971cf10b0333b81032c1ba2

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