Skip to content

[MAINT] ASR: fit_eeg_distribution docstring fixes + asr_calibrate input guards - #121

Merged
nbara merged 2 commits into
nbara:masterfrom
sappelhoff:fix/asr-calibrate-guards-docs
Jul 18, 2026
Merged

nbara merged 2 commits into
nbara:masterfrom
sappelhoff:fix/asr-calibrate-guards-docs

Conversation

@sappelhoff

Copy link
Copy Markdown
Collaborator

A small bundle of documentation and defensive-hardening fixes:

  • fit_eeg_distribution docstring: the min_clean_fraction / max_dropout_fraction default values were transposed relative to the signature (0.25 / 0.1); corrected. Also X was described as a 2-D (n_channels, n_samples) array, but the function operates on a 1-D vector of amplitude values (it does np.sort(X); n=len(X)) — description fixed.
  • asr_calibrate non-finite guard: a NaN/Inf in the calibration data previously propagated silently through the filter into M/T (an all-NaN threshold, no error). Non-finite samples are now zeroed before filtering so calibration degrades gracefully.
  • asr_calibrate insufficient-data guards: raise a clear ValueError when the calibration data is too short to form one analysis window, or yields fewer than two threshold-estimation windows — instead of an obscure downstream error.

Testing

Adds tests that non-finite calibration input yields finite M/T, and that too-short calibration raises a clear ValueError. Full tests/test_asr.py + tests/test_cov.py pass; ruff clean.


Note: includes the nonlinear_eigenspace reproducibility fix from #118 so the riemann CI test is stable regardless of what this PR changes. Once #118 merges first, that commit drops out on rebase.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.10%. Comparing base (d2f4494) to head (5e14dd6).

Files with missing lines Patch % Lines
meegkit/asr.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #121      +/-   ##
==========================================
- Coverage   83.10%   83.10%   -0.01%     
==========================================
  Files          25       25              
  Lines        2818     2823       +5     
==========================================
+ Hits         2342     2346       +4     
- Misses        476      477       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sappelhoff sappelhoff mentioned this pull request Jul 14, 2026
…ut guards

- fit_eeg_distribution: correct the transposed min_clean_fraction /
  max_dropout_fraction default values in the docstring, and describe X as
  the 1-D amplitude vector it actually is (not a 2-D array).
- asr_calibrate: zero non-finite samples before filtering so a NaN/Inf in
  the calibration data no longer propagates into a silent all-NaN
  threshold; and raise clear errors when the calibration data is too short
  to form at least two analysis windows, instead of an obscure downstream
  IndexError.
@nbara
nbara force-pushed the fix/asr-calibrate-guards-docs branch from 58ac67f to be557df Compare July 16, 2026 07:15
@nbara
nbara merged commit 6b107c9 into nbara:master Jul 18, 2026
5 of 7 checks passed
@sappelhoff
sappelhoff deleted the fix/asr-calibrate-guards-docs branch July 19, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants