From 707cc6bd08e9520c7b87b0aa3b15952b29ebae2b Mon Sep 17 00:00:00 2001 From: Abyss Halley Date: Thu, 28 Aug 2025 12:24:55 -0400 Subject: [PATCH] added logging for multiple matches instead of crashing --- testanalysis.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/testanalysis.py b/testanalysis.py index 58f62c8..a697402 100644 --- a/testanalysis.py +++ b/testanalysis.py @@ -126,14 +126,17 @@ for detection in detections.itertuples(): ) matches = injections.query(qstring) if len(matches) > 0: - logger.debug(f"Detection: DM {detection.dm} and PW {detection.pulseWidth}") - logger.debug(matches) - if len(matches) == 1: - i = matches.index[0] - matchCount[i] += 1 - logger.debug("======") - elif len(matches) > 1: - raise ValueError("MULTIPLE MATCHES OHNO") + try: + logger.debug(f"Detection: DM {detection.dm} and PW {detection.pulseWidth}") + logger.debug(matches) + if len(matches) == 1: + i = matches.index[0] + matchCount[i] += 1 + logger.debug("======") + elif len(matches) > 1: + raise ValueError("MULTIPLE MATCHES OHNO") + except ValueError: + logger.warn(f"Multiple matches found in file {detection.file}") else: #no matching injection... falsePositiveMask[detection.Index] = True logger.debug(f"NO MATCH FOR: DM {detection.dm} and PW {detection.pulseWidth}")