From 45325094438024fb9b7c2251f993efa4e3a25258 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Tue, 7 Jul 2026 11:05:04 +0200 Subject: [PATCH] fix(asr): return an estimate when geometric_median does not converge 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"). --- meegkit/utils/asr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meegkit/utils/asr.py b/meegkit/utils/asr.py index 6c5bf371..86f74d2b 100755 --- a/meegkit/utils/asr.py +++ b/meegkit/utils/asr.py @@ -387,8 +387,9 @@ def geometric_median(X, tol=1e-5, max_iter=500): y = y1 i += 1 else: - print(f"Geometric median could converge in {i} iterations " + print(f"Geometric median could not converge in {i} iterations " f"with a tolerance of {tol}") + return y def polystab(a):