From b70224dc1d395a2fe2fd26c355567df0bea6cdaf Mon Sep 17 00:00:00 2001 From: benjaminkrenn Date: Thu, 9 Jan 2020 12:38:02 +0100 Subject: [PATCH] merge --- README.md | 2 +- examples/austria_example.py | 17 ----------------- examples/austria_examples.py | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 18 deletions(-) delete mode 100644 examples/austria_example.py create mode 100644 examples/austria_examples.py diff --git a/README.md b/README.md index b7e606a..ca67015 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ D'Hondt (Jefferson) method which is indeed the [official result](https://www.bmi.gv.at/412/Europawahlen/Europawahl_2019). Another example can be found in [examples/example.py](examples/example.py). -An example with the Austrian National Council elections can be found in [examples/austria_example.py](examples/austria_example.py) +An example with the Austrian National Council elections can be found in [examples/austria_examples.py](examples/austria_examples.py) ## References diff --git a/examples/austria_example.py b/examples/austria_example.py deleted file mode 100644 index 30c4873..0000000 --- a/examples/austria_example.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import print_function -import sys -sys.path.insert(0, '..') -import apportionment - -with open("./nr_wahlen.txt", "r") as f: - - for line in f: - result = eval(line) - print(result[0]) - print(apportionment.method("dhondt", result[2], - sum(result[3]), - parties=result[1], - threshold=.04, - verbose=False)) - # actual results - print(result[3]) diff --git a/examples/austria_examples.py b/examples/austria_examples.py new file mode 100644 index 0000000..bf1e1f5 --- /dev/null +++ b/examples/austria_examples.py @@ -0,0 +1,19 @@ +from __future__ import print_function +import sys +sys.path.insert(0, '..') +import apportionment + +with open("./nr_wahlen.txt", "r") as f: + + for line in f: + year, partynames, votes, officialresult = eval(line) + print(year) + result = apportionment.method("dhondt", votes, + 183, + parties=partynames, + threshold=.04, + verbose=True) + # actual results + print("Identical with official result: " + + (str(tuple(result) == tuple(officialresult))) + + "\n\n")