Hi, ElectionManager's repr method references non-existent variables and crashes when used - AFAICT. Here's a change that I made. Two changes, actually, but the first fixes something that is a typo - AFAICT.
diff --git a/pyrankvote/helpers.py b/pyrankvote/helpers.py
index 5155e41..09c32f7 100644
--- a/pyrankvote/helpers.py
+++ b/pyrankvote/helpers.py
@@ -98,7 +98,7 @@ class ElectionManager:
ElectionManager is initialized by giving it the list of candidates and ballots,
and configure settings like number of votes each person has (used in preferential block voting)
and what to do if two voters have the same number of votes. It can then ether choose to
and what to do if two candidates have the same number of votes. It can then ether choose to
rank candidates based on the voters who has most second choice votes (and if equal third
choice votes, fourth etc.) or just choose randomly.
@@ -162,7 +162,7 @@ class ElectionManager:
self._sort_candidates_in_race()
def __repr__(self) -> str:
candidate_name_and_votes_str = ", ".join(["%s: %.2f" % (candidate_vc.name, candidate_vc.number_of_votes) for candidate_vc in self.get_candidates_in_race()])
candidate_name_and_votes_str = ", ".join(["%s: %.2f" % (candidate_vc.name, self._candidate_vote_counts[candidate_vc].number_of_votes) for candidate_vc in self.get_candidates_in_race()])
return "<ElectionManager(%s)>" % (candidate_name_and_votes_str)
Hi, ElectionManager's repr method references non-existent variables and crashes when used - AFAICT. Here's a change that I made. Two changes, actually, but the first fixes something that is a typo - AFAICT.
diff --git a/pyrankvote/helpers.py b/pyrankvote/helpers.py index 5155e41..09c32f7 100644 --- a/pyrankvote/helpers.py +++ b/pyrankvote/helpers.py @@ -98,7 +98,7 @@ class ElectionManager:
@@ -162,7 +162,7 @@ class ElectionManager: self._sort_candidates_in_race()
candidate_name_and_votes_str = ", ".join(["%s: %.2f" % (candidate_vc.name, self._candidate_vote_counts[candidate_vc].number_of_votes) for candidate_vc in self.get_candidates_in_race()])
return "<ElectionManager(%s)>" % (candidate_name_and_votes_str)
METHODS WITH SIDE-EFFECTS