STVPoll


NameSTVPoll JSON
Version 0.4.5 PyPI version JSON
download
home_pagehttps://github.com/VoteIT/STVPoll
SummarySTV polling methods
upload_time2023-03-13 10:52:39
maintainer
docs_urlNone
authorJohan Schiff & Betahaus development team
requires_python
licenseGPLv3
keywords election poll stv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            STVPoll README
==============

.. image:: https://travis-ci.org/VoteIT/STVPoll.svg?branch=master
    :target: https://travis-ci.org/VoteIT/STVPoll

Library to perform STV Poll calculations.
The package was created as part of the VoteIT project, specifically to handle larger
elections that was hard to count with Markus Schulzes STV method.

Typical usage would be primary elections or elections with many winners
from a pool of many candidates. The result will be proportional.


Fully supported:

* Scottish STV
* Instant-Runoff Voting (IRV)

Mostly working:

* CPO STV (Does not fail gracefully if too many outcomes)


Example
-------

Case from:
https://en.wikipedia.org/wiki/Single_transferable_vote


.. code-block:: python

    from stvpoll.scottish_stv import ScottishSTV

    example_ballots = (
        (['orange'], 4),
        (['pear', 'orange'], 2),
        (['chocolate', 'strawberry'], 8),
        (['chocolate', 'bonbon'], 4),
        (['strawberry'], 1),
        (['bonbon'], 1),
    )

    poll = ScottishSTV(seats=3, candidates=['orange', 'chocolate', 'pear', 'strawberry', 'bonbon'])
    for (candidates, count) in example_ballots:
        poll.add_ballot(candidates, count)

    result = poll.calculate()


This will return a ElectionResult object that contains the result and some useful metadata.
The elected attribute contains the elected candidates.

Candidates to the left have higher preference, so:
['pear', 'orange'] means 'pear' before 'orange' etc.
The number is how many of that kind of ballot there is.


.. code-block:: python

    result.elected_as_tuple()
    ('chocolate', 'orange', 'strawberry')


Code & Contributions
--------------------

You may fork the code at:
https://github.com/VoteIT/STVPoll

Please report any bugs there, or email info@voteit.se


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/VoteIT/STVPoll",
    "name": "STVPoll",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "election poll stv",
    "author": "Johan Schiff & Betahaus development team",
    "author_email": "johan@betahaus.net",
    "download_url": "https://files.pythonhosted.org/packages/08/a4/58a3c48572ee38f236170488ed41bf1810b9093bba9190c7e8159a8d9e65/STVPoll-0.4.5.tar.gz",
    "platform": null,
    "description": "STVPoll README\n==============\n\n.. image:: https://travis-ci.org/VoteIT/STVPoll.svg?branch=master\n    :target: https://travis-ci.org/VoteIT/STVPoll\n\nLibrary to perform STV Poll calculations.\nThe package was created as part of the VoteIT project, specifically to handle larger\nelections that was hard to count with Markus Schulzes STV method.\n\nTypical usage would be primary elections or elections with many winners\nfrom a pool of many candidates. The result will be proportional.\n\n\nFully supported:\n\n* Scottish STV\n* Instant-Runoff Voting (IRV)\n\nMostly working:\n\n* CPO STV (Does not fail gracefully if too many outcomes)\n\n\nExample\n-------\n\nCase from:\nhttps://en.wikipedia.org/wiki/Single_transferable_vote\n\n\n.. code-block:: python\n\n    from stvpoll.scottish_stv import ScottishSTV\n\n    example_ballots = (\n        (['orange'], 4),\n        (['pear', 'orange'], 2),\n        (['chocolate', 'strawberry'], 8),\n        (['chocolate', 'bonbon'], 4),\n        (['strawberry'], 1),\n        (['bonbon'], 1),\n    )\n\n    poll = ScottishSTV(seats=3, candidates=['orange', 'chocolate', 'pear', 'strawberry', 'bonbon'])\n    for (candidates, count) in example_ballots:\n        poll.add_ballot(candidates, count)\n\n    result = poll.calculate()\n\n\nThis will return a ElectionResult object that contains the result and some useful metadata.\nThe elected attribute contains the elected candidates.\n\nCandidates to the left have higher preference, so:\n['pear', 'orange'] means 'pear' before 'orange' etc.\nThe number is how many of that kind of ballot there is.\n\n\n.. code-block:: python\n\n    result.elected_as_tuple()\n    ('chocolate', 'orange', 'strawberry')\n\n\nCode & Contributions\n--------------------\n\nYou may fork the code at:\nhttps://github.com/VoteIT/STVPoll\n\nPlease report any bugs there, or email info@voteit.se\n\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "STV polling methods",
    "version": "0.4.5",
    "split_keywords": [
        "election",
        "poll",
        "stv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d2bcaba268e498c4aea608bff21ccf674a0983bff92d38dd9413837fc40a9aa",
                "md5": "ffdcd70b32e6331f9be23e8e81ead306",
                "sha256": "aa276574b422173abf331f1c70ea4db998f392dfe8fdb62205bddf2d0cbf22a3"
            },
            "downloads": -1,
            "filename": "STVPoll-0.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ffdcd70b32e6331f9be23e8e81ead306",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17251,
            "upload_time": "2023-03-13T10:52:37",
            "upload_time_iso_8601": "2023-03-13T10:52:37.368837Z",
            "url": "https://files.pythonhosted.org/packages/6d/2b/caba268e498c4aea608bff21ccf674a0983bff92d38dd9413837fc40a9aa/STVPoll-0.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "08a458a3c48572ee38f236170488ed41bf1810b9093bba9190c7e8159a8d9e65",
                "md5": "dbcdc5135b882ebdf967ae68c4ab1532",
                "sha256": "6464d05759e423315b040d3cc020a9ccf8e9b33df371a606bc0eb4e746b8d00e"
            },
            "downloads": -1,
            "filename": "STVPoll-0.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "dbcdc5135b882ebdf967ae68c4ab1532",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11483,
            "upload_time": "2023-03-13T10:52:39",
            "upload_time_iso_8601": "2023-03-13T10:52:39.351549Z",
            "url": "https://files.pythonhosted.org/packages/08/a4/58a3c48572ee38f236170488ed41bf1810b9093bba9190c7e8159a8d9e65/STVPoll-0.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-13 10:52:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "VoteIT",
    "github_project": "STVPoll",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": false,
    "lcname": "stvpoll"
}
        
Elapsed time: 0.04622s