examples updated

pull/7/head
Martin Lackner 2020-01-31 15:16:37 +01:00
rodzic 8febb05ac9
commit b2e2cae789
3 zmienionych plików z 16 dodań i 21 usunięć

Wyświetl plik

@ -1,18 +1,17 @@
from __future__ import print_function
import sys
sys.path.insert(0, '..')
import apportionment
import apportionment.methods as app
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)
result = app.compute("dhondt", votes,
183,
parties=partynames,
threshold=.04,
verbose=True)
# actual results
print("Identical with official result: "
+ (str(tuple(result) == tuple(officialresult)))

Wyświetl plik

@ -1,7 +1,6 @@
from __future__ import print_function
import sys
sys.path.insert(0, '..')
import apportionment
import apportionment.methods as app
print("Parties with surplus-vote agreements are treated as coalitions")
print("See https://www.knesset.gov.il/lexicon/eng/seats_eng.htm\n")
@ -12,11 +11,11 @@ with open("./knesset.txt", "r") as f:
knesset_nr, partynames, votes, officialresult, threshold = \
eval(line)
print("Knesset #" + str(knesset_nr) + ":")
result = apportionment.method("dhondt", votes,
sum(officialresult),
parties=partynames,
threshold=threshold,
verbose=True)
result = app.compute("dhondt", votes,
sum(officialresult),
parties=partynames,
threshold=threshold,
verbose=True)
# actual results
print("Identical with official result: "
+ (str(tuple(result) == tuple(officialresult)))

Wyświetl plik

@ -1,8 +1,5 @@
from __future__ import print_function
import sys
sys.path.insert(0, '..')
import apportionment
import apportionment.methods as app
votes = [77, 22, 21, 10, 6]
seats = 10
@ -14,5 +11,5 @@ print(seats, "seats", "\n")
print("apportionment results:")
for method in ["quota", "largest_remainder", "dhondt",
"saintelague", "huntington", "adams"]:
result = apportionment.method(method, votes, seats, verbose=False)
result = app.compute(method, votes, seats, verbose=False)
print(method, "."*(25 - len(method)), result)