civiqhub_selene.ordinal.counts¶
Vote counts of one item on the five-score agreement scale. Standard library only.
VoteCounts is the input of the whole ordinal family: how many votes each score
received, from -2 (strongly disagree) to +2 (strongly agree), 0 being the neutral
answer. Nothing else: neither the identity of voters, nor abstentions.
- civiqhub_selene.ordinal.counts.SCORES = (-2, -1, 0, 1, 2)¶
The five scores of the agreement scale, in order.
- class civiqhub_selene.ordinal.counts.VoteCounts(counts, name='')[source]¶
Bases:
DisplayableThe five counts of votes of one item, from score -2 to score +2.
counts[k]is the number of votes at scoreSCORES[k]. Any sequence of five non-negative integers is accepted and stored as a tuple. Shares are exact fractions, so that an equality at a threshold on paper is an equality in the code.- name¶
Free name of what was counted, for display and provenance. The engine never interprets it.
- Type:
str
- Raises:
InvalidInputError – If there are not five counts, or if a count is negative or is not an integer (a boolean and a float are refused).
- Parameters:
counts (tuple[int, int, int, int, int])
name (str)
- classmethod from_scores(scores, *, name='')[source]¶
Count a series of scores.
- Raises:
InvalidInputError – If a score is not an integer from -2 to +2.
- Parameters:
scores (Iterable[int])
name (str)
- Return type:
- property total: int¶
The number of votes: the sum of the five counts.
The five shares of votes, as exact fractions.
- Raises:
InvalidInputError – If there is no vote.
Four exact fractions: the share of votes at -2, at most -1, at most 0, at most +1.
- Raises:
InvalidInputError – If there is no vote.
- with_vote(score)[source]¶
Return new counts with one more vote at
score.- Parameters:
score (int)
- Return type:
- without_vote(score)[source]¶
Return new counts with one vote fewer at
score.- Raises:
InvalidInputError – If there is no vote at this score.
- Parameters:
score (int)
- Return type: