From 6a9fd3afb73d6170fa7c9c97cda1ea25f1cfd4f7 Mon Sep 17 00:00:00 2001 From: qubixes <44498096+qubixes@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:42:59 +0100 Subject: [PATCH] Fixed an issue in dominance computation (#28) The problem was in the case where all values are the same. Co-authored-by: Raoul Schram --- metasyncontrib/disclosure/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metasyncontrib/disclosure/utils.py b/metasyncontrib/disclosure/utils.py index 829ff59..adc6cd3 100644 --- a/metasyncontrib/disclosure/utils.py +++ b/metasyncontrib/disclosure/utils.py @@ -20,6 +20,9 @@ def _compute_dominance(block_values, reverse=False): same_vals = np.all(block_values == max_values, axis=1) diff_sum = diff_values.sum(axis=1) dominance = diff_values[~same_vals].max(axis=1) / diff_sum[~same_vals] + # If all values are the same, then dominance is 0. + if len(dominance) == 0: + return 0 return np.max(dominance)