RuleScore

class whalrus.RuleScore(*args, tie_break: whalrus.priorities.priority.Priority = Priority.UNAMBIGUOUS, converter: whalrus.converters_ballot.converter_ballot.ConverterBallot = None, **kwargs)[source]

A voting rule with scores (which are not necessarily numbers).

Each candidate is assigned a score (not necessarily a number), and the the cowinners are the candidates with the best score, in the sense defined by compare_scores().

property best_score_

The best score.

Type

object

compare_scores(one: object, another: object) → int[source]

Compare two scores.

Parameters
  • one (object) – A score.

  • another (object) – A score.

Returns

0 if they are equal, a positive number if one is greater than another, a negative number otherwise.

Return type

int

property cotrailers_

“Cotrailers”. The set of candidates with the worst score.

Type

NiceSet

property cowinners_

Cowinners. The set of candidates with the best score.

Type

NiceSet

property n_candidates_

Number of candidates.

Type

int

property order_

Result of the election as a (weak) order over the candidates. It is a list of NiceSet. The first set contains the candidates that have the best score, the second set contains those with the second best score, etc.

Type

list

property scores_

The scores. To each candidate, this dictionary assigns a score (non necessarily a number).

Type

NiceDict

property strict_order_

Result of the election as a strict order over the candidates. The first element is the winner, etc. This may use the tie-breaking rule.

Type

list

property trailer_

The “trailer” of the election. This is the last candidate in strict_order_ and also the unfavorable choice of the tie-breaking rule in cotrailers_.

Type

object

property winner_

The winner of the election. This is the first candidate in strict_order_ and also the choice of the tie-breaking rule in cowinners_.

Type

object

property worst_score_

The worst score.

Type

object