From c5f87d872af4c942f69253b297397031081a0637 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 16 Dec 2025 13:04:39 +0100 Subject: [PATCH] refactor(qav3): cleanup extrema weighting hybrid strategy logic MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- quickadapter/user_data/strategies/Utils.py | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 44885a7..2be4aab 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -729,20 +729,20 @@ def calculate_hybrid_extrema_weights( normalized_source_weights_array: list[NDArray[np.floating]] = [] for source in enabled_sources: - normalized_source_weights_array.append( - normalize_weights( - weights_array_by_source[source], - standardization=standardization, - robust_quantiles=robust_quantiles, - mmad_scaling_factor=mmad_scaling_factor, - normalization=normalization, - minmax_range=minmax_range, - sigmoid_scale=sigmoid_scale, - softmax_temperature=softmax_temperature, - rank_method=rank_method, - gamma=gamma, - ) + source_weights_arr = weights_array_by_source[source] + normalized_source_weights = normalize_weights( + source_weights_arr, + standardization=standardization, + robust_quantiles=robust_quantiles, + mmad_scaling_factor=mmad_scaling_factor, + normalization=normalization, + minmax_range=minmax_range, + sigmoid_scale=sigmoid_scale, + softmax_temperature=softmax_temperature, + rank_method=rank_method, + gamma=gamma, ) + normalized_source_weights_array.append(normalized_source_weights) if aggregation == HYBRID_AGGREGATIONS[0]: # "weighted_sum" combined_source_weights_array: NDArray[np.floating] = np.average( @@ -939,7 +939,10 @@ def _apply_weights( if weights.size == 0: return extrema - if not np.isfinite(weights).all() or np.allclose(weights, weights[0]): + if not np.isfinite(weights).all(): + return extrema + + if np.allclose(weights, weights[0]): return extrema if np.allclose(weights, DEFAULT_EXTREMA_WEIGHT): -- 2.43.0