]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(quickadapter): cleanup redundant checks in _impute_weights()
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 25 Dec 2025 15:02:10 +0000 (16:02 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 25 Dec 2025 15:02:10 +0000 (16:02 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/Utils.py

index 2e127272e758eeda17f9cf52f349c81a72341524..d78aacbe62af9523c7c7ce9ceb01f635c595c691 100644 (file)
@@ -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():