Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

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.5, 3.6 and 3.7. 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.

Files for voting, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size voting-0.1.3-py2.py3-none-any.whl (8.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size voting-0.1.3.tar.gz (7.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page