Skip to main content

Voting and election related functions.

Project description

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_loosemore_hanby

      • 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

voting-0.1.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

voting-0.1.2-py2.py3-none-any.whl (21.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file voting-0.1.2.tar.gz.

File metadata

  • Download URL: voting-0.1.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for voting-0.1.2.tar.gz
Algorithm Hash digest
SHA256 717d72daa15bc3d01592a69d13ebda27bebc311c70d466cc5850da6691beb4d1
MD5 d19bef0c34cdecd15452957cffd181f5
BLAKE2b-256 82cee7eb325d86590f71e1fc678316870696f6f7e8c006b375ada470019d0b7f

See more details on using hashes here.

File details

Details for the file voting-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: voting-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for voting-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7eb07e3e2ac4dda446163c3b43235ffba07f1fecc6fd3318e5e9bd854b9ea921
MD5 571865454485c14577874a8e5d6c3b71
BLAKE2b-256 fae2b1a80a371ca2ecdcb41d089b502332d171f529bd373adf15d56de209987b

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