wfdb-python icon indicating copy to clipboard operation
wfdb-python copied to clipboard

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

Open mj-64 opened this issue 2 years ago • 0 comments

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

mj-64 avatar Dec 11 '23 10:12 mj-64