Found in the #16 correctness/prose/comments audit (verified by running on the default log). Both bugs are present in both StepTracker notebooks (StepTracker-Exercises.ipynb and StepTracker-WithExampleSolution.ipynb).
1. Top-2 / top-3 frequencies are copy-paste duplicates. The "top 3 frequencies" extraction assigns all three to the same element:
top1_freq = freqs[ind_sorted_by_coef][0]
top2_freq = freqs[ind_sorted_by_coef][0] # should be [1]
top3_freq = freqs[ind_sorted_by_coef][0] # should be [2]
Verified on the default file the sorted top-3 are [1.545, 1.636, 3.091] Hz, but all three vars get 1.545. The variables aren't reused downstream (so no output changes), but the code is wrong and misleading to students.
2. Real-time peak detector wraps at the buffer start. In the per-buffer peak loop:
for j in range(0, len(buffer) - 1):
forward_slope = buffer[j + 1] - buffer[j]
backward_slope = buffer[j] - buffer[j - 1] # j==0 -> buffer[-1] wraps to the LAST sample
if forward_slope < 0 and backward_slope > 0:
...
At j == 0, buffer[j-1] is buffer[-1] (the last sample), so the slope test compares across the buffer seam and can flag a spurious peak at index 0. Masked by the min_peak_height threshold for the stock data, but it's a genuine off-by-one in a stub students extend. Fix: iterate range(1, len(buffer) - 1) (the one-sample buffer overlap already covers the seam).
Found in the #16 correctness/prose/comments audit (verified by running on the default log). Both bugs are present in both StepTracker notebooks (
StepTracker-Exercises.ipynbandStepTracker-WithExampleSolution.ipynb).1. Top-2 / top-3 frequencies are copy-paste duplicates. The "top 3 frequencies" extraction assigns all three to the same element:
Verified on the default file the sorted top-3 are
[1.545, 1.636, 3.091] Hz, but all three vars get1.545. The variables aren't reused downstream (so no output changes), but the code is wrong and misleading to students.2. Real-time peak detector wraps at the buffer start. In the per-buffer peak loop:
At
j == 0,buffer[j-1]isbuffer[-1](the last sample), so the slope test compares across the buffer seam and can flag a spurious peak at index 0. Masked by themin_peak_heightthreshold for the stock data, but it's a genuine off-by-one in a stub students extend. Fix: iteraterange(1, len(buffer) - 1)(the one-sample buffer overlap already covers the seam).