Report transfer values in detailed comments

This commit is contained in:
RunasSudo 2021-01-10 02:05:02 +11:00
parent 235c17b33a
commit c78a30d5b2
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 54 additions and 7 deletions

View File

@ -272,7 +272,6 @@ class BaseSTVCounter:
__pragma__('noopov') __pragma__('noopov')
# Transfer surplus # Transfer surplus
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed.')
self.do_surplus(candidate_surplus, count_card, surplus) self.do_surplus(candidate_surplus, count_card, surplus)
# Declare elected any candidates meeting the quota as a result of surpluses # Declare elected any candidates meeting the quota as a result of surpluses

View File

@ -65,6 +65,24 @@ class WIGSTVCounter(BaseSTVCounter):
transferable_votes = total_votes - exhausted_votes transferable_votes = total_votes - exhausted_votes
__pragma__('noopov') __pragma__('noopov')
__pragma__('opov')
if self.options['papers'] == 'transferable':
if transferable_votes > surplus:
if self.options['round_tvs'] is None:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + (surplus / transferable_votes).pp(2) + '.')
else:
tv = self.round_tv(surplus / transferable_votes)
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + tv.pp(2) + '.')
else:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value received.')
else:
if self.options['round_tvs'] is None:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + (surplus / total_votes).pp(2) + '.')
else:
tv = self.round_tv(surplus / total_votes)
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + tv.pp(2) + '.')
__pragma__('noopov')
for candidate, x in next_preferences.items(): for candidate, x in next_preferences.items():
cand_ballots = x[0] cand_ballots = x[0]
num_ballots = x[1] num_ballots = x[1]
@ -82,7 +100,6 @@ class WIGSTVCounter(BaseSTVCounter):
if self.options['round_tvs'] is None: if self.options['round_tvs'] is None:
self.candidates[candidate].transfers += self.round_votes((num_votes * surplus) / transferable_votes) self.candidates[candidate].transfers += self.round_votes((num_votes * surplus) / transferable_votes)
else: else:
tv = self.round_tv(surplus / transferable_votes)
self.candidates[candidate].transfers += self.round_votes(num_votes * tv) self.candidates[candidate].transfers += self.round_votes(num_votes * tv)
else: else:
self.candidates[candidate].transfers += self.round_votes(num_votes) # Do not allow weight to increase self.candidates[candidate].transfers += self.round_votes(num_votes) # Do not allow weight to increase
@ -90,7 +107,6 @@ class WIGSTVCounter(BaseSTVCounter):
if self.options['round_tvs'] is None: if self.options['round_tvs'] is None:
self.candidates[candidate].transfers += self.round_votes((num_votes * surplus) / total_votes) self.candidates[candidate].transfers += self.round_votes((num_votes * surplus) / total_votes)
else: else:
tv = self.round_tv(surplus / total_votes)
self.candidates[candidate].transfers += self.round_votes(num_votes * tv) self.candidates[candidate].transfers += self.round_votes(num_votes * tv)
__pragma__('noopov') __pragma__('noopov')
@ -238,6 +254,24 @@ class UIGSTVCounter(WIGSTVCounter):
transferable_votes = total_votes - exhausted_votes transferable_votes = total_votes - exhausted_votes
__pragma__('noopov') __pragma__('noopov')
__pragma__('opov')
if self.options['papers'] == 'transferable':
if transferable_votes > surplus:
if self.options['round_tvs'] is None:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + (surplus / transferable_ballots).pp(2) + '.')
else:
tv = self.round_tv(surplus / transferable_ballots)
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + tv.pp(2) + '.')
else:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value received.')
else:
if self.options['round_tvs'] is None:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + (surplus / total_ballots).pp(2) + '.')
else:
tv = self.round_tv(surplus / total_ballots)
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + tv.pp(2) + '.')
__pragma__('noopov')
for candidate, x in next_preferences.items(): for candidate, x in next_preferences.items():
cand_ballots = x[0] cand_ballots = x[0]
num_ballots = x[1] num_ballots = x[1]
@ -255,7 +289,6 @@ class UIGSTVCounter(WIGSTVCounter):
if self.options['round_tvs'] is None: if self.options['round_tvs'] is None:
self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / transferable_ballots) self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / transferable_ballots)
else: else:
tv = self.round_tv(surplus / transferable_ballots)
self.candidates[candidate].transfers += self.round_votes(num_ballots * tv) self.candidates[candidate].transfers += self.round_votes(num_ballots * tv)
else: else:
self.candidates[candidate].transfers += self.round_votes(num_votes) self.candidates[candidate].transfers += self.round_votes(num_votes)
@ -263,7 +296,6 @@ class UIGSTVCounter(WIGSTVCounter):
if self.options['round_tvs'] is None: if self.options['round_tvs'] is None:
self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / total_ballots) self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / total_ballots)
else: else:
tv = self.round_tv(surplus / total_ballots)
self.candidates[candidate].transfers += self.round_votes(num_ballots * tv) self.candidates[candidate].transfers += self.round_votes(num_ballots * tv)
__pragma__('noopov') __pragma__('noopov')
@ -325,6 +357,24 @@ class EGSTVCounter(UIGSTVCounter):
transferable_votes = total_votes - exhausted_votes transferable_votes = total_votes - exhausted_votes
__pragma__('noopov') __pragma__('noopov')
__pragma__('opov')
if self.options['papers'] == 'transferable':
if transferable_votes > surplus:
if self.options['round_tvs'] is None:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + (surplus / transferable_ballots).pp(2) + '.')
else:
tv = self.round_tv(surplus / transferable_ballots)
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + tv.pp(2) + '.')
else:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value received.')
else:
if self.options['round_tvs'] is None:
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + (surplus / total_ballots).pp(2) + '.')
else:
tv = self.round_tv(surplus / total_ballots)
self.logs.append('Surplus of ' + candidate_surplus.name + ' distributed at value ' + tv.pp(2) + '.')
__pragma__('noopov')
for candidate, x in next_preferences.items(): for candidate, x in next_preferences.items():
cand_ballots = x[0] cand_ballots = x[0]
num_ballots = x[1] num_ballots = x[1]
@ -342,7 +392,6 @@ class EGSTVCounter(UIGSTVCounter):
if self.options['round_tvs'] is None: if self.options['round_tvs'] is None:
self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / transferable_ballots) self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / transferable_ballots)
else: else:
tv = self.round_tv(surplus / transferable_ballots)
self.candidates[candidate].transfers += self.round_votes(num_ballots * tv) self.candidates[candidate].transfers += self.round_votes(num_ballots * tv)
else: else:
self.candidates[candidate].transfers += self.round_votes(num_votes) self.candidates[candidate].transfers += self.round_votes(num_votes)
@ -350,7 +399,6 @@ class EGSTVCounter(UIGSTVCounter):
if self.options['round_tvs'] is None: if self.options['round_tvs'] is None:
self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / total_ballots) self.candidates[candidate].transfers += self.round_votes((num_ballots * surplus) / total_ballots)
else: else:
tv = self.round_tv(surplus / total_ballots)
self.candidates[candidate].transfers += self.round_votes(num_ballots * tv) self.candidates[candidate].transfers += self.round_votes(num_ballots * tv)
__pragma__('noopov') __pragma__('noopov')