Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with _blinkreconstruct_recursive #19

Closed
navidivan opened this issue Dec 12, 2023 · 1 comment
Closed

problem with _blinkreconstruct_recursive #19

navidivan opened this issue Dec 12, 2023 · 1 comment

Comments

@navidivan
Copy link

In the _blinkreconstruct_recursive function, processed_blink_points is used to keep track of blink points processed in recursive calls. Since this list is not reinitialized on subsequent function calls, it retains its state from previous runs, leading to the "infinite loop" warning and incorrect behavior in subsequent runs.

To fix this issue, you should initialize processed_blink_points within the function rather than using it as a default argument. Here's the corrected version of _blinkreconstruct_recursive:

python

def _blinkreconstruct_recursive(a, vt_start=10, vt_end=5, maxdur=500, margin=10,
gap_margin=20, gap_vt=10, smooth_winlen=21,
std_thr=3, processed_blink_points=None):
"""Implements a recursive blink-reconstruction algorithm."""

# Initialize processed_blink_points if it's None
if processed_blink_points is None:
    processed_blink_points = []

def fnc_recursive(a):
    """Shortcut for recursive function call that retains all keywords."""
    return _blinkreconstruct_recursive(
        a, vt_start=vt_start, vt_end=vt_end, maxdur=maxdur, margin=margin,
        gap_margin=gap_margin, gap_vt=gap_vt, smooth_winlen=smooth_winlen,
        std_thr=std_thr, processed_blink_points=processed_blink_points)

# ... rest of the function

return fnc_recursive(a)

With this change, processed_blink_points is initialized as an empty list on each top-level call to _blinkreconstruct_recursive, preventing the retention of state across different invocations of the function.

@smathot
Copy link
Collaborator

smathot commented Dec 13, 2023

Thanks for spotting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants