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

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'})