From: Jérôme Benoit Date: Fri, 19 Dec 2025 23:30:14 +0000 (+0100) Subject: fix(qav3): do not weight the first pivot if cannot be computed X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=81e22f44f0bb2c1aeb156fd6ee9005d840d4cc6c;p=freqai-strategies.git fix(qav3): do not weight the first pivot if cannot be computed Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 521e041..638e2e4 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -535,7 +535,12 @@ def _impute_weights( finite_mask: NDArray[np.bool_] | None = None, default_weight: float = DEFAULT_EXTREMA_WEIGHT, ) -> NDArray[np.floating]: - weights = weights.astype(float, copy=False) + weights = weights.astype(float, copy=True) + + # weights computed by zigzag have NaN on first element if it cannot be computed correctly + if len(weights) > 0 and not np.isfinite(weights[0]): + weights[0] = 0.0 + if finite_mask is None: finite_mask = np.isfinite(weights) @@ -546,9 +551,9 @@ def _impute_weights( if not np.isfinite(median_weight): median_weight = default_weight - weights_out = weights.astype(float, copy=True) - weights_out[~finite_mask] = median_weight - return weights_out + weights[~finite_mask] = median_weight + + return weights def normalize_weights(