class whalrus.ScorerBucklin(*args, k: int = 1, unordered_receive_points: Optional[bool] = True, absent_receive_points: Optional[bool] = True, **kwargs)[source]

Scorer for Bucklin’s rule.

  • args – Cf. parent class.
  • k (int) – The number of points to distribute. Intuitively: the k candidates at the highest ranks will receive 1 point each. In case of tie, some points may be divided between the tied candidates (see below).
  • unordered_receive_points (bool or None.) – Whether unordered candidates should receive points (see below).
  • absent_receive_points (bool or None.) – Whether absent candidates should receive points (see below).
  • kwargs – Cf. parent class.


Typical usage:

>>> ScorerBucklin(BallotOrder('a > b > c > d > e'),
...               candidates={'a', 'b', 'c', 'd', 'e'}, k=2).scores_
{'a': 1, 'b': 1, 'c': 0, 'd': 0, 'e': 0}

In the example below, candidates a, b and c are “ordered”, d and e are “unordered”, and f and g are “absent” in the ballot, meaning that they were not even available when the voter cast her ballot. By default, we count as if the unordered candidates were below the ordered candidates, and the absent candidates even lower:

>>> ballot = BallotOrder('a > b ~ c', candidates={'a', 'b', 'c', 'd', 'e'})
>>> candidates_election = {'a', 'b', 'c', 'd', 'e', 'f', 'g'}
>>> ScorerBucklin(ballot, candidates=candidates_election, k=2).scores_as_floats_
{'a': 1.0, 'b': 0.5, 'c': 0.5, 'd': 0.0, 'e': 0.0, 'f': 0.0, 'g': 0.0}
>>> ScorerBucklin(ballot, candidates=candidates_election, k=4).scores_as_floats_
{'a': 1.0, 'b': 1.0, 'c': 1.0, 'd': 0.5, 'e': 0.5, 'f': 0.0, 'g': 0.0}
>>> ScorerBucklin(ballot, candidates=candidates_election, k=6).scores_as_floats_
{'a': 1.0, 'b': 1.0, 'c': 1.0, 'd': 1.0, 'e': 1.0, 'f': 0.5, 'g': 0.5}

Using the options, unordered and/or absent candidates can always receive 0 point, or even not be mentioned in the score dictionary at all:

>>> ScorerBucklin(ballot, candidates=candidates_election, k=6,
...     unordered_receive_points=False, absent_receive_points=None).scores_
{'a': 1, 'b': 1, 'c': 1, 'd': 0, 'e': 0}

The scores, given as floats. It is the same as scores_, but converted to floats.

Like all conversions to floats, it is advised to use this attribute for display purposes only. For computation, you should always use scores_, which usually manipulates fractions and therefore allows for exact computation.

Raises:ValueError – If the scores cannot be converted to floats.