From 103eccd89ed87af0aeff1c74ae1560520a5c9bfa Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 15 Jun 2025 21:56:08 +0200 Subject: [PATCH] refactor(qav3): align cache variable namespace MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../freqaimodels/QuickAdapterRegressorV3.py | 18 +++++++++--------- quickadapter/user_data/strategies/Utils.py | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index d9bbac3..b29d39e 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -1366,7 +1366,7 @@ def zigzag( last_pivot_pos = pos reset_candidate_pivot() - slopes_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} + slope_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} def get_slope_ok( pos: int, @@ -1383,16 +1383,16 @@ def zigzag( min_slope, ) - if cache_key in slopes_ok_cache: - return slopes_ok_cache[cache_key] + if cache_key in slope_ok_cache: + return slope_ok_cache[cache_key] next_start = pos next_end = min(next_start + slope_confirmation_window, n) next_closes = closes[next_start:next_end] if len(next_closes) < 2: - slopes_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + slope_ok_cache[cache_key] = False + return slope_ok_cache[cache_key] log_next_closes = np.log(next_closes) log_next_closes_length = len(log_next_closes) @@ -1408,13 +1408,13 @@ def zigzag( )[0] if direction == TrendDirection.DOWN: - slopes_ok_cache[cache_key] = log_next_slope < -min_slope + slope_ok_cache[cache_key] = log_next_slope < -min_slope elif direction == TrendDirection.UP: - slopes_ok_cache[cache_key] = log_next_slope > min_slope + slope_ok_cache[cache_key] = log_next_slope > min_slope else: - slopes_ok_cache[cache_key] = False + slope_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + return slope_ok_cache[cache_key] def is_pivot_confirmed( pos: int, diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 4f1c1db..ad88660 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -490,7 +490,7 @@ def zigzag( last_pivot_pos = pos reset_candidate_pivot() - slopes_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} + slope_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} def get_slope_ok( pos: int, @@ -507,16 +507,16 @@ def zigzag( min_slope, ) - if cache_key in slopes_ok_cache: - return slopes_ok_cache[cache_key] + if cache_key in slope_ok_cache: + return slope_ok_cache[cache_key] next_start = pos next_end = min(next_start + slope_confirmation_window, n) next_closes = closes[next_start:next_end] if len(next_closes) < 2: - slopes_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + slope_ok_cache[cache_key] = False + return slope_ok_cache[cache_key] log_next_closes = np.log(next_closes) log_next_closes_length = len(log_next_closes) @@ -532,13 +532,13 @@ def zigzag( )[0] if direction == TrendDirection.DOWN: - slopes_ok_cache[cache_key] = log_next_slope < -min_slope + slope_ok_cache[cache_key] = log_next_slope < -min_slope elif direction == TrendDirection.UP: - slopes_ok_cache[cache_key] = log_next_slope > min_slope + slope_ok_cache[cache_key] = log_next_slope > min_slope else: - slopes_ok_cache[cache_key] = False + slope_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + return slope_ok_cache[cache_key] def is_pivot_confirmed( pos: int, -- 2.43.0