From 76079a288d095c248551bc4a73d01179c01047ea Mon Sep 17 00:00:00 2001 From: mohaminn Date: Thu, 20 Feb 2025 14:56:51 +0100 Subject: [PATCH] Update _split.py Replaced the previous implementation of _get_list_periodic_pattern_pos() which used a while loop with an optimized implementation using range(). --- aaanalysis/feature_engineering/_backend/cpp/_split.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/aaanalysis/feature_engineering/_backend/cpp/_split.py b/aaanalysis/feature_engineering/_backend/cpp/_split.py index 37ce213b..7a7b554f 100644 --- a/aaanalysis/feature_engineering/_backend/cpp/_split.py +++ b/aaanalysis/feature_engineering/_backend/cpp/_split.py @@ -37,14 +37,8 @@ def _get_list_pattern_pos(steps=None, n_min=2, n_max=4, len_max=15): def _get_list_periodic_pattern_pos(len_seq=None, step1=None, step2=None, pos=1): """Get list of periodic pattern positions""" - list_pos = [pos] - while pos <= len_seq: - if len(list_pos) % 2 != 0: - pos += step1 - else: - pos += step2 - if pos <= len_seq: - list_pos.append(pos) + stride = step1 + step2 + list_pos = list(range(pos,len_seq, stride)) + list(range((pos + step1),len_seq, stride)) return list_pos