into [ {"count":5, "ballot": {'A':1, 'B':2, 'fish':3, 'love':0, ... } } ]. The format has been changed from BALLOT_NOTATION_GROUPING into the usual format for the program.
This is a result of how Python handles arguments - it's pass by reference, not pass by value. There are 2 ways to deal with this:
Remove the ballot_notation argument when you run it twice, e.g.
Alternatively, if you really don't want votes itself to change formats for some reason, you can always use the deepcopy function to make a dummy clone for the program. This will leave the value of votes intact.
from copy import deepcopy
SchulzeMethod( deepcopy(votes), ballot_notation=CondorcetHelper.BALLOT_NOTATION_GROUPING)
SchulzeMethod( deepcopy(votes), ballot_notation=CondorcetHelper.BALLOT_NOTATION_GROUPING)
Sorry if this isn't issue worthy, it's just a quirk of the software I felt would be good to point out. Certainly tripped me up when I was learning it.
Hey Brad et al,
I'm not sure if this is a bug but I thought it would be good to mention for anyone else who runs across it. I'm running py3votecore in Python 3.6.
When I run
twice in a row, it fails the second time. You get back an
AttributeError: 'dict' object has no attribute 'reverse'
fromstandardize_ballots
.The reason: If you look at the
votes
argument, you'll see that it has been changed from the example-given ballot notation, which looks likeinto
[ {"count":5, "ballot": {'A':1, 'B':2, 'fish':3, 'love':0, ... } } ]
. The format has been changed from BALLOT_NOTATION_GROUPING into the usual format for the program.This is a result of how Python handles arguments - it's pass by reference, not pass by value. There are 2 ways to deal with this:
Remove the
ballot_notation
argument when you run it twice, e.g.SchulzeMethod( votes, ballot_notation=CondorcetHelper.BALLOT_NOTATION_GROUPING) SchulzeMethod( votes )
Alternatively, if you really don't want
votes
itself to change formats for some reason, you can always use thedeepcopy
function to make a dummy clone for the program. This will leave the value ofvotes
intact.from copy import deepcopy SchulzeMethod( deepcopy(votes), ballot_notation=CondorcetHelper.BALLOT_NOTATION_GROUPING) SchulzeMethod( deepcopy(votes), ballot_notation=CondorcetHelper.BALLOT_NOTATION_GROUPING)
Sorry if this isn't issue worthy, it's just a quirk of the software I felt would be good to point out. Certainly tripped me up when I was learning it.