Ranking Module
- class hivemind.ranking.Ranking[source]
Bases:
object
A class for managing ranked choice voting.
This class handles both fixed and automatic ranking of options in the Hivemind protocol. It supports different ranking strategies including fixed rankings and automatic rankings based on proximity to a preferred choice.
- Variables:
- get(options: List[HivemindOption] | None = None) List[str] [source]
Get the ranked choices.
- Parameters:
options (List[HivemindOption] | None) – List of HivemindOptions, required for auto ranking
- Returns:
A list of option cids in ranked order
- Return type:
List[str]
- Raises:
Exception – If ranking is not set or options are invalid for auto ranking
- set_auto_high(choice: str) None [source]
Set the ranking to auto high.
The ranking will be calculated at runtime by given options, ordered by the values closest to preferred choice. In case 2 options are equally distant to preferred choice, the higher option has preference.
- set_auto_low(choice: str) None [source]
Set the ranking to auto low.
The ranking will be calculated at runtime by given options, ordered by the values closest to preferred choice. In case 2 options are equally distant to preferred choice, the lower option has preference.