Skip to content

Commit 474de66

Browse files
committed
Replace uninformative RuntimeError for custom AlgorithmError. Verify cells are not empty in PsfMatch
1 parent 902279c commit 474de66

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

python/lsst/ip/diffim/psfMatch.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,20 @@ def _solve(self, kernelCellSet, basisList):
858858
ksv.resetKernelSum()
859859
ksv.setMode(diffimLib.KernelSumVisitorF.AGGREGATE)
860860
kernelCellSet.visitCandidates(ksv, nStarPerCell, ignoreExceptions=True)
861-
ksv.processKsumDistribution()
861+
862+
allCellsEmpty = True
863+
for cell in kernelCellSet.getCellList():
864+
if not cell.empty():
865+
allCellsEmpty = False
866+
break
867+
if allCellsEmpty:
868+
raise NoKernelCandidatesError("All spatial cells are emtpy of candidates")
869+
870+
try:
871+
ksv.processKsumDistribution()
872+
except RuntimeError as e:
873+
raise NoKernelCandidatesError("Unable to calculate the kernel sum") from e
874+
862875
ksv.setMode(diffimLib.KernelSumVisitorF.REJECT)
863876
kernelCellSet.visitCandidates(ksv, nStarPerCell, ignoreExceptions=True)
864877

0 commit comments

Comments
 (0)