Repository navigation
Match WFDB C rounding for smoothed digital frames - #821
Conversation
eec50d3 to
f4eccbc
Compare
tompollard
left a comment
There was a problem hiding this comment.
Thanks, the rounding matches the C change exactly: floor(q) + (r >= ceil(n/2)) is equivalent to C's floor((sum + n/2) / n), ties included, and it can't overflow. On real data, the first frame of 041s (raw III samples 168 168 166 164) now gives III=167, I=-42, V=139, matching the C formula applied to the raw samples, where main gave 166 and 138. The offline suite, Ruff and the strict docs build pass locally.
One thing to fix: the changelog only mentions digital reads, but physical uniform reads of multi-frequency records change too, since they're derived from the rounded digital values. On the PR's own test file, the physical values go from [0.0, 0.0, 0.005, -0.005] on main to [0.005, 0.0, 0.01, -0.005]. Could the entry say that uniform reads of multi-frequency records, digital and physical, can differ by up to one ADC unit?
Optional: if WFDB ≥ 10.7 is available, regenerating the reference files behind test_4a, test_4b and test_4c would let them assert exact values again instead of a one-unit tolerance.
|
Thanks. I updated the changelog in c9cab04 to say uniform reads of multi-frequency records are affected, including physical values derived from the rounded digital samples; the difference can be up to one ADC unit. I have not regenerated the C reference files because the C tools are not installed here. The new targeted tests assert the exact rounding rule, and the existing reference tests retain the one-unit tolerance. |
tompollard
left a comment
There was a problem hiding this comment.
Thanks, the changelog now covers both digital and physical uniform reads. The rounding is unchanged from what I checked against the C formula. Not regenerating the reference files without the C tools is fine. The full offline suite, Ruff and the strict docs build pass locally.
Ready to merge once CI is green.
Summary
meansampchange. Use quotient and remainder so the rounding step cannot overflow anint64sum.rdrecordandread_signals.Fixes #335.
Checks
FutureWarningtreated as an error: 1,548 passed, 4 skipped.