[FIX] ASR: round half away from zero for window/bad-chan counts#116
[FIX] ASR: round half away from zero for window/bad-chan counts#116sappelhoff wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #116 +/- ##
==========================================
+ Coverage 83.11% 83.12% +0.01%
==========================================
Files 25 25
Lines 2825 2827 +2
==========================================
+ Hits 2348 2350 +2
Misses 477 477 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Note: includes the |
numpy's np.round (banker's rounding) and int() truncation diverge from MATLAB's round-half-away-from-zero at exact-half inputs, giving +-1 counts for the bad-channel count and window length N in clean_windows and asr_calibrate. Add a _round_half_away helper and apply it at those sites.
b89951f to
f496f9d
Compare
|
This one is probably a bit unnecessary, unless "matlab parity" is a goal, which I don't see why it should be. |
|
It was at the beginning as I tried to get identical numerical results vs the reference implementation (Matlab). But I agree now it's not such a problem anymore |
|
I will leave it up to you to merge or close :) I think both would be fine |
numpy's
np.round(banker's rounding, round-half-to-even) and Python'sint()truncation diverge from MATLAB's round-half-away-from-zero at exact-half inputs, giving ±1 counts for the bad-channel count and window lengthNinclean_windowsandasr_calibrate. Add a_round_half_awayhelper and apply it at those sites.Reachability is narrow (ties need specific channel counts or odd-integer
sfreqwithwin_len=0.5; common rates never trigger), so this mainly hardens the edge cases.Testing
Added a helper unit test covering ties (
2.5→3,128.5→129,-2.5→-3), divergence fromnp.round, array input, andint()exactness. Fulltests/test_asr.pypasses;ruffclean.