From 5de19d6d05b4460f8f2a5561dd8878cd62302f45 Mon Sep 17 00:00:00 2001 From: Lan <ldam@passcal.nmt.edu> Date: Thu, 18 May 2023 12:18:41 -0600 Subject: [PATCH] change code to not remove quest_chans that not includes in plotting data --- sohstationviewer/view/util/functions.py | 7 ++++--- tests/test_view/test_util_functions.py | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sohstationviewer/view/util/functions.py b/sohstationviewer/view/util/functions.py index 60e2883b3..68bd436b3 100644 --- a/sohstationviewer/view/util/functions.py +++ b/sohstationviewer/view/util/functions.py @@ -359,9 +359,10 @@ def replace_actual_quest_chans( for qc in quest_chans: actual_quest_chans = [c for c in list(actual_chans) if qc[:-1] == c[:-1]] - quest_idx = chan_order.index(qc) - chan_order.remove(qc) - chan_order[quest_idx:quest_idx] = sorted(actual_quest_chans) + if actual_quest_chans: + quest_idx = chan_order.index(qc) + chan_order.remove(qc) + chan_order[quest_idx:quest_idx] = sorted(actual_quest_chans) return chan_order diff --git a/tests/test_view/test_util_functions.py b/tests/test_view/test_util_functions.py index eedfa5481..60fb1c205 100644 --- a/tests/test_view/test_util_functions.py +++ b/tests/test_view/test_util_functions.py @@ -520,10 +520,18 @@ class RemoveNotFoundChansClass(TestCase): class ReplaceActualQuestChans(TestCase): - def test_replace_actual_quest_chans(self): + def test_quest_chans_in_actual_chans(self): chan_order = ['A', 'B', 'C?', 'D'] actual_chans = ['C1', 'C3', 'C2', 'D', 'E', 'F'] expected_new_chan_order = ['A', 'B', 'C1', 'C2', 'C3', 'D'] ret = replace_actual_quest_chans(chan_order, actual_chans) self.assertListEqual(ret, expected_new_chan_order) + + def test_quest_chans_not_in_actual_chans(self): + chan_order = ['A?', 'B', 'C', 'D'] + actual_chans = ['C', 'D', 'E', 'F'] + expected_new_chan_order = ['A?', 'B', 'C', 'D'] + + ret = replace_actual_quest_chans(chan_order, actual_chans) + self.assertListEqual(ret, expected_new_chan_order) -- GitLab