Skip to content

[FIX] ASR: correct reconstruction dim count, blend seam, and RMS window rounding#111

Merged
nbara merged 1 commit into
nbara:masterfrom
sappelhoff:fix/asr-reconstruction
Jul 20, 2026
Merged

[FIX] ASR: correct reconstruction dim count, blend seam, and RMS window rounding#111
nbara merged 1 commit into
nbara:masterfrom
sappelhoff:fix/asr-reconstruction

Conversation

@sappelhoff

Copy link
Copy Markdown
Collaborator

Three independent fixes in the calibration/reconstruction path:

  • maxdims / keep-mask off-by-one in asr_process: maxdims used np.fix (truncate toward zero) instead of round-half-away, and the keep-mask index term protected one component too many. The spec converts the fractional 0.66 factor with round-half-away-from-zero, and its 1-based (1:C) < (C - maxdims) protects C-maxdims-1 components, so use int(np.floor(0.66 * nc + 0.5)) and np.arange(nc) < nc - maxdims - 1. Together these made the code under-remove artifact dimensions.
  • Raised-cosine blend endpoint in asr_process: np.arange(ns)/ns never reaches 1, so the block's final sample kept a residual fraction of the previous reconstruction. Shift the phase to np.arange(1, ns + 1)/ns so blend[-1] = 1.0 and the last sample equals the new reconstruction.
  • RMS window starts in asr_calibrate: the step N*(1-win_overlap) was rounded before building the window starts, drifting from the correct positions for a non-integer step (biasing mu/sig/T). Extract a _rms_window_offsets helper that rounds each start (matching clean_windows).

Testing

Adds a regression test for each. Full tests/test_asr.py passes; ruff clean.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (3b0c530) to head (873385b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
+ Coverage   83.15%   83.16%   +0.01%     
==========================================
  Files          25       25              
  Lines        2832     2834       +2     
==========================================
+ Hits         2355     2357       +2     
  Misses        477      477              

☔ 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

Copy link
Copy Markdown
Collaborator Author

Note: includes the nonlinear_eigenspace reproducibility fix from #118 (needed for the riemann path to have stable CI). Once #118 merges, this commit will drop out on rebase.

@sappelhoff
sappelhoff force-pushed the fix/asr-reconstruction branch from ee56321 to ae71732 Compare July 13, 2026 17:10
@sappelhoff sappelhoff mentioned this pull request Jul 14, 2026
@sappelhoff
sappelhoff force-pushed the fix/asr-reconstruction branch from 2e68047 to db658e5 Compare July 19, 2026 09:13
…ow rounding

Three independent fixes in the calibration/reconstruction path:

- maxdims / keep-mask off-by-one in asr_process: maxdims used np.fix
  (truncate toward zero) instead of round-half-away, and the keep-mask
  index term protected one component too many. The spec converts the
  fractional 0.66 factor with round-half-away-from-zero, and its 1-based
  (1:C) < (C - maxdims) protects C-maxdims-1 components, so use
  int(np.floor(0.66 * nc + 0.5)) and np.arange(nc) < nc - maxdims - 1.
  Together these made meegkit under-remove artifact dimensions.

- Raised-cosine blend endpoint in asr_process: np.arange(ns)/ns never
  reaches 1, so the block's final sample kept a residual fraction of the
  previous reconstruction. Shift the phase to np.arange(1, ns + 1)/ns so
  blend[-1] = 1.0 and the last sample equals the new reconstruction.

- RMS window starts in asr_calibrate: the step N*(1-win_overlap) was
  rounded before building the window starts, drifting from the correct
  positions for a non-integer step (biasing mu/sig/T). Extract a
  _rms_window_offsets helper that rounds each start (matching clean_windows).

Adds a regression test for each.
@nbara
nbara force-pushed the fix/asr-reconstruction branch from db658e5 to 873385b Compare July 20, 2026 13:23
@nbara
nbara merged commit 8e53091 into nbara:master Jul 20, 2026
7 checks passed
@sappelhoff
sappelhoff deleted the fix/asr-reconstruction branch July 20, 2026 13:34
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