Skip to content

Commit

Permalink
float STV
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkho committed Sep 4, 2024
1 parent 0b63d16 commit c844a76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions whalrus/rules_committee/rule_stv.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,26 @@ def get_rounds_(self):
selection(rule=rule, threshold = self.quota)

for candidate in selection.selected_:
elected[candidate] = rule.gross_scores_[candidate]
elected[candidate] = float(rule.gross_scores_[candidate])

if not selection.is_above_:

elimination = EliminationLast(rule=rule, k=1)
new_set = elimination.qualified_
e = next(iter(elimination.eliminated_))
eliminated[e] = rule.gross_scores_[e]
eliminated[e] = float(rule.gross_scores_[e])
selection = elimination
else:
new_profile = selection.new_profile_
new_set = selection.remaining_
rule(new_profile, candidates=new_set)
remaining = {c: rule.gross_scores_[c] for c in new_set}
remaining = {c: float(rule.gross_scores_[c]) for c in new_set}
rounds.append((copy.deepcopy(selection), elected.copy(), remaining,eliminated.copy()))
if len(rule.candidates_) + len(elected) == self.committee_size:
for candidate in rule.candidates_:
elected[candidate] = rule.gross_scores_[candidate]
elected[candidate] = float(rule.gross_scores_[candidate])
rounds[-1] = (selection, elected,{}, eliminated)

return rounds
return rounds

4 changes: 2 additions & 2 deletions whalrus/selections/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ def new_profile_(self):

if len(ballot) >= 1 and ballot.first() not in self.selected_:
ballots.append(ballot.restrict(new_set))
weights.append(weight)
weights.append(float(weight))

elif len(ballot) > 1 and self.get_winner_ratio_[ballot.first()] > 0:

ballots.append(ballot.restrict(new_set))
weights.append(weight*self.get_winner_ratio_[ballot.first()])

return Profile(ballots, weights = weights)


Expand Down

0 comments on commit c844a76

Please sign in to comment.