From 5dfaec222309b3895335fdfe01ec4cef077ed1b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 17 May 2025 18:46:58 +0200 Subject: [PATCH] refactor(qav3): cleanup pivot labeling implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../user_data/freqaimodels/QuickAdapterRegressorV3.py | 6 +++--- quickadapter/user_data/strategies/Utils.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 1641a44..06551dd 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -912,7 +912,7 @@ def zigzag( return np.clip(depth_factor, min_factor, max_factor) def calculate_depth( - pivots_indices: list[int], + pos: int, min_depth: int = 5, max_depth: int = 30, ) -> int: @@ -923,7 +923,7 @@ def zigzag( weights = np.linspace(0.5, 1.5, len(previous_periods)) average_period = np.average(previous_periods, weights=weights) - depth_factor = calculate_depth_factor(last_pivot_pos) + depth_factor = calculate_depth_factor(pos) depth = int(average_period * depth_factor) return np.clip(depth, min_depth, max_depth) @@ -970,7 +970,7 @@ def zigzag( pivots_values.append(value) pivots_directions.append(direction) last_pivot_pos = pos - depth = calculate_depth(pivots_indices) + depth = calculate_depth(pos) def is_reversal_confirmed( candidate_pivot_pos: int, diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 61d3683..0af17a5 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -408,7 +408,7 @@ def zigzag( return np.clip(depth_factor, min_factor, max_factor) def calculate_depth( - pivots_indices: list[int], + pos: int, min_depth: int = 5, max_depth: int = 30, ) -> int: @@ -419,7 +419,7 @@ def zigzag( weights = np.linspace(0.5, 1.5, len(previous_periods)) average_period = np.average(previous_periods, weights=weights) - depth_factor = calculate_depth_factor(last_pivot_pos) + depth_factor = calculate_depth_factor(pos) depth = int(average_period * depth_factor) return np.clip(depth, min_depth, max_depth) @@ -466,7 +466,7 @@ def zigzag( pivots_values.append(value) pivots_directions.append(direction) last_pivot_pos = pos - depth = calculate_depth(pivots_indices) + depth = calculate_depth(pos) def is_reversal_confirmed( candidate_pivot_pos: int, -- 2.43.0