Wybory - przeliczanie głosów. A pure Python module for election quotas, voting measures, and apportionment methods.
 
 
Go to file
crflynn 029c877551 update twine 2018-11-03 10:33:06 -04:00
docs chg doc title [ci skip] 2018-01-08 23:11:47 -05:00
tests tests 2018-01-08 22:12:31 -05:00
voting add manifest 2018-01-08 22:56:32 -05:00
.gitignore initial commit 2018-01-06 20:55:14 -05:00
.travis.yml travis 2018-01-08 22:16:18 -05:00
HISTORY.rst add manifest 2018-01-08 22:56:32 -05:00
LICENSE.txt initial commit 2018-01-06 20:55:14 -05:00
MANIFEST.in add manifest 2018-01-08 22:56:32 -05:00
Pipfile add setup.cfg 2018-01-08 22:44:32 -05:00
Pipfile.lock update twine 2018-11-03 10:33:06 -04:00
README.rst add badges [ci skip] 2018-01-08 23:10:22 -05:00
pytest.ini tests 2018-01-08 22:12:31 -05:00
requirements-dev.txt reqs for rtd builds [ci skip] 2018-01-08 23:03:06 -05:00
setup.cfg add setup.cfg 2018-01-08 22:44:32 -05:00
setup.py add setup.py 2018-01-07 16:50:01 -05:00
tox.ini tox 2018-01-08 22:14:37 -05:00

README.rst

voting
======

|travis| |rtd| |codecov| |pypi| |pyversions|


.. |travis| image:: https://img.shields.io/travis/crflynn/voting.svg
    :target: https://travis-ci.org/crflynn/voting

.. |rtd| image:: https://img.shields.io/readthedocs/voting.svg
    :target: http://voting.readthedocs.io/en/latest/

.. |codecov| image:: https://codecov.io/gh/crflynn/voting/branch/master/graphs/badge.svg
    :target: https://codecov.io/gh/crflynn/voting

.. |pypi| image:: https://img.shields.io/pypi/v/voting.svg
    :target: https://pypi.python.org/pypi/voting

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/voting.svg
    :target: https://pypi.python.org/pypi/voting


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.

.. code-block:: shell

    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.

.. code-block:: python

    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.

.. code-block:: python

    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.

.. code-block:: python

    from voting import proportion


    votes = [750, 150, 50, 50]
    seats = [80, 16, 2, 2]
    disproportionality = proportion.sainte_lague(votes, seats)

Determining the Droop quota

.. code-block:: python

    from voting import quota


    votes = 1000
    seats = 20
    election_quota = quota.droop(votes, seats)