ConverterBallotToPlurality¶
-
class
whalrus.
ConverterBallotToPlurality
(priority: whalrus.priorities.priority.Priority = Priority.UNAMBIGUOUS, order_priority: whalrus.priorities.priority.Priority = None, plurality_priority: whalrus.priorities.priority.Priority = None, veto_priority: whalrus.priorities.priority.Priority = None, one_name_priority: whalrus.priorities.priority.Priority = None)[source]¶ Default converter to a
BallotPlurality
.- Parameters
priority (Priority) – Serves as a default value for the other parameters if they are not explicitly mentioned. Default:
Priority.UNAMBIGUOUS
.order_priority (Priority) – Option passed to
BallotOrder.first()
. Default:priority
.plurality_priority (Priority) – Option passed to
BallotPlurality.first()
. Default:priority
.veto_priority (Priority) – Option passed to
BallotVeto.first()
. Default:priority
.one_name_priority (Priority) – Option passed to
BallotOneName.first()
. Default:priority
.
Examples
Typical usages:
>>> converter = ConverterBallotToPlurality() >>> converter(BallotOneName('a', candidates={'a', 'b'})) BallotPlurality('a', candidates={'a', 'b'}) >>> converter(BallotVeto('a', candidates={'a', 'b'})) BallotPlurality('b', candidates={'a', 'b'}) >>> converter({'a': 10, 'b': 7, 'c':0}) BallotPlurality('a', candidates={'a', 'b', 'c'}) >>> converter('a > b ~ c') BallotPlurality('a', candidates={'a', 'b', 'c'}) >>> converter(['a', {'b', 'c'}]) BallotPlurality('a', candidates={'a', 'b', 'c'})
Use options for the restrictions:
>>> converter = ConverterBallotToPlurality(priority=Priority.ASCENDING) >>> converter('a ~ b > c') BallotPlurality('a', candidates={'a', 'b', 'c'})
Misc:
>>> ballot = BallotVeto('a', candidates={'a', 'b', 'c'}) >>> converter = ConverterBallotToPlurality() >>> converter(ballot, candidates={'a', 'b', 'd'}) BallotPlurality('b', candidates={'a', 'b'})