Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion peakdet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,15 @@ def check_troughs(data, peaks, troughs=None):
troughs : np.ndarray
Indices of trough locations in `data`, dependent on `peaks`
"""
if peaks is None or len(peaks) == 0:
return np.array([])
if len(peaks) == 1:
return np.array([])

# If there's a trough after all peaks, keep it.
if troughs is not None and troughs[-1] > peaks[-1]:
all_troughs = np.zeros(peaks.size, dtype=int)
assert all_troughs[-1] == troughs[-1]
all_troughs[-1] = troughs[-1]
else:
all_troughs = np.zeros(peaks.size - 1, dtype=int)

Expand Down