Skip to main content

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

voting-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

voting-0.1.0-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: voting-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for voting-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b891d04dd407b52cd8cd223dece0341dadc86b15c6b137ae4750c54294ad09d
MD5 4d0ecc3b30011e5df20f0000cf8b4a3c
BLAKE2b-256 27158a97153ba054c5b9b71bdce47c43498bb33234d3b65ae80a9042085387c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for voting-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 25d35bfbfd84677f53419f058ccd8cbf253a14c85345b1c6fc8e30391b5db1ca
MD5 378f889176a65ed51e609dbe5834e947
BLAKE2b-256 2491915f6e09d7cb06e2a4e3e531185c62c40538b362d21b871e7f41f6c44a9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page