From 7ca6de2d1561781fcc1de23d8b344543fcbeaacf Mon Sep 17 00:00:00 2001 From: Ashley Wright Date: Sat, 30 Nov 2024 07:38:14 +0300 Subject: [PATCH] Improve deviation detection --- validator/weight_setting/winner_selection.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/validator/weight_setting/winner_selection.py b/validator/weight_setting/winner_selection.py index 21d50d00..1df065dd 100644 --- a/validator/weight_setting/winner_selection.py +++ b/validator/weight_setting/winner_selection.py @@ -34,13 +34,17 @@ def get_contestant_ranks(scores: dict[Key, float]) -> dict[Key, int]: scores = list(sorted(scores.items(), key=itemgetter(1), reverse=True)) score_values = list(map(itemgetter(1), scores)) - deviation = median(score_values[i] - score_values[i + 1] for i in range(len(score_values) - 1)) + deviation = median( + score_values[i] - score_values[i + 1] + for i in range(len(score_values) - 1) + if score_values[i + 1] > 0 and score_values[i] - score_values[i + 1] > 0.0001, + ) scores = iter(scores) hotkey, last_score = next(scores) - ranks = {hotkey: rank} + ranks = { hotkey: rank } for hotkey, score in scores: difference = last_score - score