Skip to content

Commit

Permalink
Move name check to start, sort printed list in error
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Dec 17, 2024
1 parent 5921319 commit 7957a6c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7957a6c

Please sign in to comment.