BallotVeto

class whalrus.BallotVeto(b: object, candidates: set = None)[source]

A veto (anti-plurality) ballot.

Examples

>>> ballot = BallotVeto('a', candidates={'a', 'b', 'c'})
>>> print(ballot)
a
>>> ballot = BallotVeto(None, candidates={'a', 'b', 'c'})
>>> print(ballot)
None
property candidates_in_b

The candidate that is explicitly mentioned in the ballot.

This is a singleton with the only candidate contained in the ballot (or an empty set in case of abstention).

Examples

>>> BallotOneName('a', candidates={'a', 'b', 'c'}).candidates_in_b
{'a'}
>>> BallotOneName(None, candidates={'a', 'b', 'c'}).candidates_in_b
{}
Type

NiceSet

property candidates_not_in_b

The candidates that were available at the moment of the vote, but are not explicitly mentioned in the ballot.

Examples

>>> BallotOneName('a', candidates={'a', 'b', 'c'}).candidates_not_in_b
{'b', 'c'}
Type

NiceSet

first(candidates: set = None, **kwargs) → object[source]

Examples

>>> BallotVeto('a', candidates={'a', 'b'}).first()
'b'
>>> BallotVeto('a', candidates={'a', 'b', 'c'}).first(priority=Priority.ASCENDING)
'b'
last(candidates: set = None, **kwargs) → object[source]

Examples

>>> BallotVeto('a', candidates={'a', 'b', 'c'}).last()
'a'
>>> BallotVeto('a', candidates={'a', 'b', 'c'}).last(candidates={'b', 'c'},
...                                                  priority=Priority.ASCENDING)
'c'
restrict(candidates: set = None, **kwargs) → whalrus.ballots.ballot_one_name.BallotOneName

Restrict the ballot to less candidates.

Parameters
  • candidates (set of candidates) – It can be any set of candidates, not necessarily a subset of self.candidates). Default: self.candidates.

  • kwargs

Returns

The same ballot, “restricted” to the candidates given.

Return type

BallotOneName

Examples

>>> BallotOneName('a', candidates={'a', 'b'}).restrict(candidates={'b'})
BallotOneName('b', candidates={'b'})
>>> BallotOneName('a', candidates={'a', 'b', 'c'}).restrict(candidates={'b', 'c'},
...                                                         priority=Priority.ASCENDING)
BallotOneName('b', candidates={'b', 'c'})