Skip to content
Diversity / (dis)proportionality measures, election quotas, and apportionment methods in pure Python.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs chg doc title [ci skip] Jan 9, 2018
tests
voting
.gitignore
.travis.yml
HISTORY.rst add manifest Jan 9, 2018
LICENSE.txt
MANIFEST.in add manifest Jan 9, 2018
Pipfile
Pipfile.lock update twine Nov 3, 2018
README.rst
pytest.ini
requirements-dev.txt
requirements.txt try requirements Dec 21, 2018
setup.cfg
setup.py add setup.py Jan 7, 2018
tox.ini

README.rst

voting

travis rtd codecov pypi pyversions

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)
You can’t perform that action at this time.