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

Readme example fails #25

Open
rdixit opened this issue May 28, 2016 · 2 comments
Open

Readme example fails #25

rdixit opened this issue May 28, 2016 · 2 comments

Comments

@rdixit
Copy link

rdixit commented May 28, 2016

In [19]: ballots
Out[19]:
[{'ballot': [['A'], ['C'], ['D'], ['B']], 'count': 3},
{'ballot': [['B'], ['A'], ['C'], ['D']], 'count': 9},
{'ballot': [['C'], ['D'], ['A'], ['B']], 'count': 8},
{'ballot': [['D'], ['A'], ['B'], ['C']], 'count': 5},
{'ballot': [['D'], ['B'], ['C'], ['A']], 'count': 5}]

In [20]: SchulzeMethod(ballots, ballot_notation = "grouping").as_dict()

Exception Traceback (most recent call last)
in ()
----> 1 SchulzeMethod(ballots, ballot_notation = "grouping").as_dict()

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/schulze_method.py in init(self, ballots, tie_breaker, ballot_notation)
25 ballots,
26 tie_breaker=tie_breaker,
---> 27 ballot_notation=ballot_notation,
28 )
29

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/condorcet.py in init(self, ballots, tie_breaker, ballot_notation)
108 @AbstractMethod
109 def init(self, ballots, tie_breaker=None, ballot_notation=None):
--> 110 self.standardize_ballots(ballots, ballot_notation)
111 super(CondorcetSystem, self).init(self.ballots, tie_breaker=tie_breaker)
112

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/condorcet.py in standardize_ballots(self, ballots, ballot_notation)
48 ballot["ballot"][candidate] = float(rating)
49 else:
---> 50 raise Exception("Unknown notation specified", ballot_notation)
51
52 self.candidates = set()

Exception: ('Unknown notation specified', 'grouping')

In [21]: SchulzeMethod(ballots).as_dict()

AttributeError Traceback (most recent call last)
in ()
----> 1 SchulzeMethod(ballots).as_dict()

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/schulze_method.py in init(self, ballots, tie_breaker, ballot_notation)
25 ballots,
26 tie_breaker=tie_breaker,
---> 27 ballot_notation=ballot_notation,
28 )
29

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/condorcet.py in init(self, ballots, tie_breaker, ballot_notation)
108 @AbstractMethod
109 def init(self, ballots, tie_breaker=None, ballot_notation=None):
--> 110 self.standardize_ballots(ballots, ballot_notation)
111 super(CondorcetSystem, self).init(self.ballots, tie_breaker=tie_breaker)
112

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/condorcet.py in standardize_ballots(self, ballots, ballot_notation)
45 elif ballot_notation == CondorcetHelper.BALLOT_NOTATION_RATING or ballot_notation is None:
46 for ballot in self.ballots:
---> 47 for candidate, rating in ballot["ballot"].iteritems():
48 ballot["ballot"][candidate] = float(rating)
49 else:

AttributeError: 'list' object has no attribute 'iteritems'

In [22]: SchulzeMethod(ballots)

AttributeError Traceback (most recent call last)
in ()
----> 1 SchulzeMethod(ballots)

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/schulze_method.py in init(self, ballots, tie_breaker, ballot_notation)
25 ballots,
26 tie_breaker=tie_breaker,
---> 27 ballot_notation=ballot_notation,
28 )
29

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/condorcet.py in init(self, ballots, tie_breaker, ballot_notation)
108 @AbstractMethod
109 def init(self, ballots, tie_breaker=None, ballot_notation=None):
--> 110 self.standardize_ballots(ballots, ballot_notation)
111 super(CondorcetSystem, self).init(self.ballots, tie_breaker=tie_breaker)
112

/Users/rohan/Dropbox/PROJECTS/crowdocracy/pyvotecore/condorcet.py in standardize_ballots(self, ballots, ballot_notation)
45 elif ballot_notation == CondorcetHelper.BALLOT_NOTATION_RATING or ballot_notation is None:
46 for ballot in self.ballots:
---> 47 for candidate, rating in ballot["ballot"].iteritems():
48 ballot["ballot"][candidate] = float(rating)
49 else:

AttributeError: 'list' object has no attribute 'iteritems'

@bradbeattie
Copy link
Owner

Try the examples in test_functionality/test_schulze_method.py instead. I think the format was changed and the README was never updated.

@rdixit
Copy link
Author

rdixit commented May 28, 2016

That worked! Thank you!

Up to you to close the issue or not. Appreciate your eyes on this Brad.

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

2 participants