From 7957a6c3aa4f787070325ed22ba0145574b40221 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Tue, 17 Dec 2024 14:37:59 -0500 Subject: [PATCH] Move name check to start, sort printed list in error --- jdaviz/app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jdaviz/app.py b/jdaviz/app.py index 3e7b1748ff..7cf3c2956f 100644 --- a/jdaviz/app.py +++ b/jdaviz/app.py @@ -959,6 +959,10 @@ def get_subsets(self, subset_name=None, spectral_only=False, if subset_name is not None: if isinstance(subset_name, str): subsets = [subset for subset in subsets if subset.label == subset_name] + if subsets == []: + all_labels = [sg.label for sg in dc.subset_groups] + all_labels.sort() + raise ValueError(f"{subset_name} not in {all_labels}") else: raise ValueError("subset_name must be a string.") @@ -1027,10 +1031,8 @@ def get_subsets(self, subset_name=None, spectral_only=False, else: all_subsets[label] = subset_region - if subset_name and subset_name in all_subsets: + if subset_name: return all_subsets[subset_name] - elif subset_name: - raise ValueError(f"{subset_name} not in {all_subsets.keys()}") else: return all_subsets