From 77903719bca449fad49080aaa26115335de3859d Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Tue, 10 Sep 2024 07:46:50 -0700 Subject: [PATCH] In CI mode, only raise if there are zero parents to deblend. --- python/lsst/meas/deblender/sourceDeblendTask.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/lsst/meas/deblender/sourceDeblendTask.py b/python/lsst/meas/deblender/sourceDeblendTask.py index b181e12..a3f850d 100644 --- a/python/lsst/meas/deblender/sourceDeblendTask.py +++ b/python/lsst/meas/deblender/sourceDeblendTask.py @@ -307,15 +307,17 @@ def deblend(self, exposure, srcs, psf): minChildren, maxChildren = self.config.ciDeblendChildRange nPeaks = np.array([len(src.getFootprint().peaks) for src in srcs]) childrenInRange = np.where((nPeaks >= minChildren) & (nPeaks <= maxChildren))[0] - if len(childrenInRange) < self.config.ciNumParentsToDeblend: - raise ValueError("Fewer than ciNumParentsToDeblend children were contained in the range " - "indicated by ciDeblendChildRange. Adjust this range to include more " - "parents.") + numParentsToDeblend = self.config.ciNumParentsToDeblend + if len(childrenInRange) < numParentsToDeblend: + # Only use the top N instead of the full requested list. + if len(childrenInRange) == 0: + raise ValueError("No children to deblend; cannot continue with CI testing.") + numParentsToDeblend = len(childrenInRange) # Keep all of the isolated parents and the first # `ciNumParentsToDeblend` children parents = nPeaks == 1 children = np.zeros((len(srcs),), dtype=bool) - children[childrenInRange[:self.config.ciNumParentsToDeblend]] = True + children[childrenInRange[:numParentsToDeblend]] = True srcs = srcs[parents | children] # We need to update the IdFactory, otherwise the the source ids # will not be sequential