From 594bde96339795813177f3bfb5de435978b03eba Mon Sep 17 00:00:00 2001 From: Conor McNamara Date: Thu, 27 Mar 2025 17:33:51 -0700 Subject: [PATCH] Change robust.py to avoid UnboundLocalError If a user specifies a threshold, current implementation calls for `s` before it is initialized, creating UnboundLocalError. We have now fixed that problem. --- pysyncon/robust.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pysyncon/robust.py b/pysyncon/robust.py index c7af946..2866465 100644 --- a/pysyncon/robust.py +++ b/pysyncon/robust.py @@ -101,7 +101,7 @@ def _sv_decomposition( """ if not threshold and not sv_count: raise ValueError("One of `threshold` or `sv_count` must be supplied.") - + u, s, v = np.linalg.svd(Y) if threshold: idx = 0 while s[idx] > threshold: @@ -109,7 +109,6 @@ def _sv_decomposition( else: idx = sv_count - u, s, v = np.linalg.svd(Y) s_res = np.zeros_like(Y) s_res[:idx, :idx] = np.diag(s[:idx])