[FIX] ASR: round half away from zero for window/bad-chan counts#116
Open
sappelhoff wants to merge 2 commits into
Open
[FIX] ASR: round half away from zero for window/bad-chan counts#116sappelhoff wants to merge 2 commits into
sappelhoff wants to merge 2 commits into
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #116 +/- ##
=======================================
Coverage 83.10% 83.11%
=======================================
Files 25 25
Lines 2818 2819 +1
=======================================
+ Hits 2342 2343 +1
Misses 476 476 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nonlinear_eigenspace drew its optimization starting point from an unseeded module-level Generator, so the riemann ASR path produced slightly different results on every call. The starting point only affects convergence, not the resulting eigenspace, so seed it with a fixed value. This makes the riemann ASR output reproducible run-to-run and stabilizes the incremental-vs-bulk equivalence check in test_asr_class. Adds a regression test asserting repeated calls return identical results.
Collaborator
Author
|
Note: includes the |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.