From 4f6e75915abe12ef5475111de170bb4ebd7cb3d3 Mon Sep 17 00:00:00 2001 From: Jakob Lass Date: Thu, 21 Aug 2025 11:41:15 +0200 Subject: [PATCH] Correct initialization of convergence loop --- src/AMBER/background.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/AMBER/background.py b/src/AMBER/background.py index 355c5a6..dd974b5 100644 --- a/src/AMBER/background.py +++ b/src/AMBER/background.py @@ -613,11 +613,10 @@ class background(): # Loss function loss = []#np.zeros(n_epochs, dtype=self.dtype) - old_loss = 2000000 - new_loss = 1000000 + old_loss = 0 + new_loss = 0 k = 0 - - while (old_loss - new_loss > 1e-3) and (k < n_epochs): + while ((old_loss - new_loss > 1e-3) and (k < n_epochs)) or k < 2: # Compute A = Y - B by filling the nans with 0s A = np.where(np.isnan(Y_r - b_tmp) == True, 0.0, Y_r - b_tmp)