Skip to content

[FIX] ASR: return an estimate when geometric_median does not converge#107

Merged
sappelhoff merged 2 commits into
nbara:masterfrom
sappelhoff:fix/asr-geometric-median-nonconvergence
Jul 10, 2026
Merged

[FIX] ASR: return an estimate when geometric_median does not converge#107
sappelhoff merged 2 commits into
nbara:masterfrom
sappelhoff:fix/asr-geometric-median-nonconvergence

Conversation

@sappelhoff

Copy link
Copy Markdown
Collaborator

Summary

When the Vardi–Zhang iteration in geometric_median reached max_iter without
meeting the tolerance, the while ... else branch only printed a message and
the function fell through to an implicit return None, which breaks callers
(asr_calibrate / asr_process reshape the result). Return the last iterate
y instead, which is the best estimate available.

The message wording is also fixed ("could converge" → "could not converge").

Correctness

  • The converged path is unchanged.
  • On non-convergence the function now returns a correctly-shaped array instead
    of None (verified with a forced single-iteration run).

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.10%. Comparing base (1606601) to head (df34644).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
meegkit/utils/asr.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #107      +/-   ##
==========================================
- Coverage   83.13%   83.10%   -0.03%     
==========================================
  Files          25       25              
  Lines        2817     2818       +1     
==========================================
  Hits         2342     2342              
- Misses        475      476       +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.

@nbara nbara changed the title fix(asr): return an estimate when geometric_median does not converge [FIX] ASR: return an estimate when geometric_median does not converge Jul 7, 2026
When the Vardi-Zhang iteration hit `max_iter` without meeting the
tolerance, the `while...else` branch only printed a message and the
function fell through to an implicit `return None`, which would break
callers (`asr_calibrate` / `asr_process` reshape the result). Return the
last iterate `y` instead, which is the best estimate available.

Also fix the message wording ("could converge" -> "could not
converge").
@nbara nbara force-pushed the fix/asr-geometric-median-nonconvergence branch from 38425ba to 4532509 Compare July 10, 2026 14:03
@sappelhoff sappelhoff merged commit 3721224 into nbara:master Jul 10, 2026
5 checks passed
@sappelhoff sappelhoff deleted the fix/asr-geometric-median-nonconvergence branch July 10, 2026 14:48
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