Skip to content

Third loop in wfdb.processing.peaks.find_local_peaks will not be executed and can be removed #474

Closed

Description

@mj-64

In find_local_peaks() in wfdb.processing.peaks, the last of three loops will not be execute because the condition i < len(sig) is already false when the second loop exits:
[first loop omitted]

while i < len(sig):
    if sig[i] == max(sig[i - radius : i + radius]):
        peak_inds.append(i)
        i += radius
    else:
        i += 1

while i < len(sig):
    if sig[i] == max(sig[i - radius :]):
        peak_inds.append(i)
        i += radius
    else:
        i += 1

Activity

  1. TheNetherWatcher commented on Nov 1, 2026

    @TheNetherWatcher
    Contributor

    I think this one can be closed: #573 replaced the three loops in find_local_peaks with a single loop over a window clipped to the edges of the signal, so the unreachable third loop is gone.

  2. tompollard commented on Nov 21, 2026

    @tompollard
    Member

    Confirmed fixed by #573 (commit 4d7fa00). find_local_peaks now uses one loop over the whole signal with the search window clipped to the signal edges, so the unreachable third loop is gone. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions