From 925aa4a2bba9b69ddad1d5be978706e49697ec08 Mon Sep 17 00:00:00 2001 From: "E. Joshua Rigler" <erigler@usgs.gov> Date: Fri, 21 Mar 2025 09:41:31 -0600 Subject: [PATCH] Fix UnboundLocalError in SNCL.py: I neglected to run unit tests before the previous commit, and failed to notice that a returned variable could possibly be undefined. Fixed. --- geomagio/edge/LegacySNCL.py | 5 +---- geomagio/edge/SNCL.py | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/geomagio/edge/LegacySNCL.py b/geomagio/edge/LegacySNCL.py index b3330c7c..12999e2a 100644 --- a/geomagio/edge/LegacySNCL.py +++ b/geomagio/edge/LegacySNCL.py @@ -146,9 +146,7 @@ def _get_channel_end(element: str, data_type: str) -> str: channel_middle = "K" elif element in ["F", "G"]: channel_middle = "S" - channel_end = element.split("_")[0] if data_type == "variation" or data_type[0] == "R": - channel_end = element.split("_") if len(channel_end) == 1: channel_end = channel_end[0] if channel_end == "U": @@ -157,8 +155,7 @@ def _get_channel_end(element: str, data_type: str) -> str: channel_end = "E" elif channel_end == "W": channel_end = "Z" - else: - channel_end = channel_end[0] + channel_end = channel_end[0][0] # 2nd [0] ensures a single character return channel_middle + channel_end diff --git a/geomagio/edge/SNCL.py b/geomagio/edge/SNCL.py index 51aa7712..6975ef7f 100644 --- a/geomagio/edge/SNCL.py +++ b/geomagio/edge/SNCL.py @@ -177,8 +177,8 @@ def _get_channel_end(element: str, data_type: str) -> str: channel_middle = "Y" elif "_Temp" in element: channel_middle = "K" + channel_end = element.split("_") if data_type == "variation" or data_type[0] == "R": - channel_end = element.split("_") if len(channel_end) == 1: channel_end = channel_end[0] if channel_end == "H": @@ -187,8 +187,7 @@ def _get_channel_end(element: str, data_type: str) -> str: channel_end = "V" elif channel_end == "Z": channel_end = "W" - else: - channel_end = channel_end[0] + channel_end = channel_end[0][0] # 2nd [0] ensures a single character return channel_middle + channel_end -- GitLab