From 104cab96ad5034df2d4ec28302381c1225006b57 Mon Sep 17 00:00:00 2001 From: Lorenzo Gaifas Date: Fri, 6 Sep 2024 13:15:28 +0200 Subject: [PATCH] use min instead of comparison (#34) --- src/fidder/erase/sparse_local_mean.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fidder/erase/sparse_local_mean.py b/src/fidder/erase/sparse_local_mean.py index f29db8a..e27dfcd 100644 --- a/src/fidder/erase/sparse_local_mean.py +++ b/src/fidder/erase/sparse_local_mean.py @@ -41,8 +41,7 @@ def estimate_local_mean( # get a random set of foreground pixels for the background fit foreground_sample_idx = np.argwhere(mask == 1) - if n_background_samples := len(foreground_sample_idx) < n_samples_for_fit: - n_samples_for_fit = n_background_samples + n_samples_for_fit = min(n_samples_for_fit, len(foreground_sample_idx)) selection = np.random.choice( foreground_sample_idx.shape[0], size=n_samples_for_fit, replace=False )