From: Jérôme Benoit Date: Thu, 25 Dec 2025 15:02:10 +0000 (+0100) Subject: refactor(quickadapter): cleanup redundant checks in _impute_weights() X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e84b1cc78d4f4c4ddf2c1e4f1cef368579a3b56e;p=freqai-strategies.git refactor(quickadapter): cleanup redundant checks in _impute_weights() Signed-off-by: Jérôme Benoit --- 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():