[FIX] ASR: tolerate flat/degenerate segments in fit_eeg_distribution#120
Open
sappelhoff wants to merge 1 commit into
Open
[FIX] ASR: tolerate flat/degenerate segments in fit_eeg_distribution#120sappelhoff wants to merge 1 commit into
sappelhoff 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 #120 +/- ##
=======================================
Coverage 83.11% 83.12%
=======================================
Files 25 25
Lines 2825 2826 +1
=======================================
+ Hits 2348 2349 +1
Misses 477 477 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Open
The vectorized grid-search histogram divided by a per-column baseline- relative value that is zero for a run of tied samples (e.g. a flatlined channel), producing inf/nan bin values; casting nan to int gave INT64_MIN and np.bincount raised ValueError. A flat segment is exactly the dropout case max_dropout_fraction is meant to tolerate. Make the binning ignore non-finite entries (count them in no bin) so the grid search degrades gracefully instead of crashing; results on finite input are unchanged. Fixes a crash reachable via ASR.fit() on data with a dead channel.
sappelhoff
force-pushed
the
fix/asr-fit-flat-channel
branch
from
July 19, 2026 09:07
d4c2adc to
85c2a6d
Compare
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.
fit_eeg_distribution's vectorized grid-search histogram divides by a per-column baseline-relative value that is zero when a run of samples is tied (e.g. a flatlined / disconnected electrode):cols = nbins / newX[mcurr]→inf, thenH = newX[:m] * cols→nan(0·inf). Castingnanto int yieldsINT64_MIN, andnp.bincountthen raisesValueError: 'list' argument must have no negative elements.A flat segment is exactly the dropout case
max_dropout_fractionis meant to tolerate, so the fit should degrade gracefully rather than crash. This makes the histogram binning ignore non-finite entries (count them in no bin), so a degenerate grid column just yields a poor — but finite — objective and the grid search continues. Results on finite input are unchanged.The crash is reachable through the primary public entry point:
ASR().fit(X)with a single dead channel currently raisesValueError.Testing
Adds three tests: the direct
fit_eeg_distributioncrash on a tied/flat vector;ASR().fit()with a dead channel; and a guard that the result on clean data is numerically identical (samemu, sig, alpha, beta). Fulltests/test_asr.py+tests/test_cov.pypass;ruffclean.Note: includes the
nonlinear_eigenspacereproducibility fix from #118 so the riemann CI test (test_asr_class[*-riemann]) is stable regardless of what this PR changes. Once #118 merges first, that commit drops out on rebase.