RuleScoreNumAverage(*args, scorer: whalrus.scorers.scorer.Scorer = None, default_average: numbers.Number = 0, **kwargs)¶
A voting rule where each candidate’s score is an average of the scores provided by the ballots.
- args – Cf. parent class.
- scorer (Scorer) – For each ballot, it is in charge of computing its contribution to each candidate’s score.
- default_average (Number) – The default average score of a candidate when it receives no score whatsoever. It may happen, for example, if all voters abstain about this candidate. This avoids a division by zero when computing this candidate’s average score.
- kwargs – Cf. parent class.
RuleRangeVotingfor some examples.
The average score.
The average score as a float. It is the same as
average_score_, but converted to a float.
The best score as a float. It is the same as
RuleScore.best_score_, but converted to a float.
compare_scores(one: numbers.Number, another: numbers.Number) → int¶
Compare two scores.
- one (object) – A score.
- another (object) – A score.
0 if they are equal, a positive number if
oneis greater than
another, a negative number otherwise.
The gross scores of the candidates. For each candidate, this dictionary gives the sum of its scores, multiplied by the weights of the corresponding voters. This is the numerator in the candidate’s average score.
Gross scores as floats. It is the same as
gross_scores_, but converted to floats.
Number of candidates.
Scores as floats. It is the same as
scores_, but converted to floats.
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.
The weights used for the candidates. For each candidate, this dictionary gives the total weight for this candidate, i.e. the total weight of all voters who assign a score to this candidate. This is the denominator in the candidate’s average score.
Weights as floats. It is the same as
weights_, but converted to floats.