Skip to content

Readme example fails #25

Description

@rdixit

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions