From e84b1cc78d4f4c4ddf2c1e4f1cef368579a3b56e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 25 Dec 2025 16:02:10 +0100 Subject: [PATCH] refactor(quickadapter): cleanup redundant checks in _impute_weights() 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 2e12727..d78aacb 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -542,10 +542,11 @@ def _impute_weights( weights = weights.astype(float, copy=True) # Weights computed by `zigzag` can be NaN on boundary pivots - if len(weights) > 0 and not np.isfinite(weights[0]): - weights[0] = 0.0 - if len(weights) > 0 and not np.isfinite(weights[-1]): - weights[-1] = 0.0 + if len(weights) > 0: + if not np.isfinite(weights[0]): + weights[0] = 0.0 + if not np.isfinite(weights[-1]): + weights[-1] = 0.0 finite_mask = np.isfinite(weights) if not finite_mask.any(): -- 2.43.0