Giter Site home page Giter Site logo

bohdanbobrowski / pyrlament Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 10.72 MB

Python library for counting and visualizing seats in the Sejm of the Republic of Poland

Home Page: https://www.pyrlament.pl

License: MIT License

Python 98.81% Makefile 1.19%
dhondt election elections-2019 parliament python sejm dhont-method elections-2023 python3 wybory

pyrlament's Introduction

pyRLAMENT Library logo

Licence Python GitHub

pyRLAMENT

Python library for visualizing seats in the Sejm of the Republic of Poland. So far still in development. Its main goal is to practice the capabilities of Python on various platforms (web/mobile/desktop).

SeatsCounter:

from pyrlament import SeatsCounter
from pyrlament.data import Party

election2019 = {
    Party(name="PiS", support=43.59, threshold=8),
    Party(name="KO", support=27.4, threshold=8),
    Party(name="Lewica", support=12.56),
    Party(name="PSL", label="Polska 2050-PSL", support=10.8, threshold=8, color="DCB44B"),
    Party(name="Konfederacja", support=6.81),
}
election = SeatsCounter(parties=election2019)
election.count()

As a result of the operation of the count method, the parties parameter will contain information about the seats in the parliament, ex.:

for party in election.parties:
    print(f"{party.name}: {party.seats}")

...should print:

PiS: 235,
KO: 134,
Lewica: 49,
PSL: 30
Konfederacja: 11
Mniejszość niemiecka: 1

SeatsGenerator:

from pyrlament import SeatsGenerator 

g = SeatsGenerator(parties=election.parties)
g.randomize()
with open('pyrlament.svg', 'w') as f:
    f.write(g.svg())

SVG example:

pyRLAMENT example

PNG example:

Known bug: for some reason png output is missing logotype.

pyRLAMENT example

Tests coverage

Module statements missing excluded coverage
pyrlament/init.py 4 0 0 100%
pyrlament/configs.py 13 0 0 100%
pyrlament/counter.py 93 0 0 100%
pyrlament/data.py 68 0 0 100%
pyrlament/generator.py 289 167 0 42%
Total 467 167 0 64%

Implemented and planned features

Here are my plans (some already implemented) for this library:

  • count seats basing on election support
  • cover code with unit tests
  • 5% and 8% support threshold
  • check if all support does not reach 100%
  • draw svg with seats
  • randomise seats colors
  • split seats between parties
  • improve seats placement (it's a bit messy)
  • svg output
  • fix png output (I've implemented workaround)
  • build webapp using Flask
  • build mobile app using Kivy
  • build desktop app using Kivy
  • cli interface for library

pyrlament's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.