Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in ElectionManager #18

Open
mbaugher opened this issue Dec 22, 2021 · 0 comments
Open

Problem in ElectionManager #18

mbaugher opened this issue Dec 22, 2021 · 0 comments

Comments

@mbaugher
Copy link

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)
    

    METHODS WITH SIDE-EFFECTS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant