peaks_over_thresh should not find 2 peaks with equal snr and template
I ran into this in gstreamer_python_upgrade
due to a large number of peaks having inf
snr, but technically it can happen in O4-dev as well.
When we find peaks, we count the number of unique ones, and rely on a logical guarantee that there won't be more than max_npeak = num_templates/2
. However, because we don't don't handle the case that 2 peaks have equal snr, we can wind up exceeding the predicted max_npeak
.
max_npeak
is used for various complicated bits of memory allocation, and our pipeline either segfaults, or worse, doesn't segfault and overwrites its own memory, when we have more peaks than expected. For safety's sake, we should fix it.
The only change we need is to replace tmp_maxsnr[jlen] < tmp_maxsnr[ilen]
with tmp_maxsnr[jlen] <= tmp_maxsnr[ilen]