Voting and election related functions.
Project description
A pure Python module for election quotas, voting measures, and apportionment methods.
Installation
The voting package works in Python 2.7, 3.4, 3.5, 3.6. It is available on pypi and can be installed using pip.
pip install voting
Package structure
voting
apportionment
adams
dhondt
hagenbach_bischoff
hamilton
huntington_hill
jefferson
sainte_lague
vinton
webster
diversity
berger_parker
general
gini_simpson
golosov
inverse_simpson
laakso_taagepera
renyi
shannon
simpson
proportion
adjusted
dhondt
gallagher
grofman
least_square
lijphart
loosemore_hanby
rae
regression
rose
sainte_lague
quota
droop
hagenbach_bischoff
hare
imperiali
Examples
Apportioning seats using the Huntington-Hill method.
from voting import apportionment
votes = [2560, 3315, 995, 5012]
seats = 20
assignments = apportionment.huntington_hill(votes, seats)
Calculating the effective number of parties using Golosov’s measure.
from voting import diversity
parties = [750, 150, 50, 50]
effective_parties = diversity.golosov(parties)
Measuring the disproportionality of democratic representation using the Sainte-Lague measure.
from voting import proportion
votes = [750, 150, 50, 50]
seats = [80, 16, 2, 2]
disproportionality = proportion.sainte_lague(votes, seats)
Determining the Droop quota
from voting import quota
votes = 1000
seats = 20
election_quota = quota.droop(votes, seats)
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
Built Distribution
File details
Details for the file voting-0.1.1.tar.gz
.
File metadata
- Download URL: voting-0.1.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 243388dcfa064b9b4aab52bf2a51673794f9efdd683e019a35f9a3f6e056fcc6 |
|
MD5 | 85498743c8873174641136ba33efb1c6 |
|
BLAKE2b-256 | aec023a29ac8840e36da99f0a0643a15d595f21f706347a9f718aac89ffcb706 |
File details
Details for the file voting-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: voting-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30291ab121529faf00c942e7dbf251b60a17586a7a78f92b47b6b8f6231754d5 |
|
MD5 | de7bf8fbf7e55e45113c18a20d99ebd4 |
|
BLAKE2b-256 | 623d37edd52494a1ccc0ab0dcc2f1d84d86418c2ab69a90c27c362b84eeb5ccf |