Skip to content
@wahlwerk

Wahlwerk

Electoral systems as rules-as-code: replay real elections under any version of a law.

wahlwerk

Electoral and parliamentary systems as rules-as-code. A deterministic Python engine that replays real election results under any version of an electoral law, so that a reform can be tested seat by seat against history.

The engine knows no country: apportionment methods, thresholds and Ausgleich are general building blocks, and a system is a composition of them. The first systems implemented are German Landtage.

An electoral law is written as a protocol: an ordered tuple of small, frozen steps, each citing the section it implements (Sec. 35 (8) LWG LSA). Applying it to the votes of an election returns the chamber. A counterfactual is the same votes under a different protocol: change one step, replay, compare.

Reproduced exactly

Every implemented law is held to the official result, party by party, Wahlkreis and list seats alike, in a golden test.

Landtag Law Seats
Sachsen-Anhalt 2021 LWG LSA 97 (83 raised for Mehrsitze)
Sachsen-Anhalt 2026 LWG LSA 83
Mecklenburg-Vorpommern 2011 LKWG M-V 71
Mecklenburg-Vorpommern 2016 LKWG M-V 71
Mecklenburg-Vorpommern 2021 LKWG M-V 79 (Überhang and Ausgleich)

Repositories

wahlwerk is the package; the other repositories feed it data, use it or show its results.

Repo What it holds
wahlwerk the package and engine: laws as protocols, pydantic models, exact arithmetic (Fraction, never float), ties as results
wahlwerk-data election data for the engine: normalised bundles and party registries, each with source, licence and SHA-256
wahlwerk-ui seat charts for the engine: dependency-free SVG, the optional extra wahlwerk[ui]
wahlwerk-site the website: each component of the engine explained with elections it reproduces

Principles

  • Golden tests are the product. A law counts as implemented when it reproduces the official Sitzverteilung exactly.
  • Exact arithmetic. Float rounding hides real ties and manufactures fake ones.
  • Ties are a result. Where the law prescribes a Losentscheid, the engine returns a Tie instead of letting sort order decide.
  • Sources travel with the data. Every bundle carries its publisher, licence and the attribution the publisher requires.

Not in scope: forecasting, voter-behaviour models, simulating the Bundesverfassungsgericht.

Licence

Code is GPL-3.0. Election data keeps the licence of its source (usually dl-de/by-2-0), recorded in each bundle.

Popular repositories Loading

  1. wahlwerk wahlwerk Public

    The wahlwerk package: an engine for electoral and parliamentary systems as rules-as-code. It replays real election results under any version of a law, seat for seat, with exact arithmetic.

    Python

  2. wahlwerk-data wahlwerk-data Public

    Election data for the wahlwerk engine: normalised result bundles and party registries, each with its source, licence and SHA-256.

  3. wahlwerk-ui wahlwerk-ui Public

    Seat charts for the wahlwerk engine: dependency-free SVG hemicycles and half pies, installed as the optional extra wahlwerk[ui].

    Python

  4. wahlwerk-site wahlwerk-site Public

    The wahlwerk website: how the engine turns votes into seats, explained with real elections it reproduces exactly.

    Svelte

  5. .github .github Public

    Public profile and shared community files (contributing guide, issue templates) for the wahlwerk organisation.

Repositories

Showing 5 of 5 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…