Skip to content

Commit

Permalink
Simplify _get_item_metadata
Browse files Browse the repository at this point in the history
list comprehension is little clunky but avoids the 1-length special
case: cleaner overall
  • Loading branch information
ajjackson committed Sep 20, 2024
1 parent aaaa25a commit 87f32a0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions euphonic/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,8 @@ def _get_item_metadata(self, item): # noqa: F811
return metadata_lines[item]
if isinstance(item, slice):
return self._combine_metadata(metadata_lines[item])
if len(item) == 1:
return metadata_lines[item[0]]
return self._combine_metadata(
list(itemgetter(*item)(metadata_lines)))
# Item must be some kind of integer sequence
return self._combine_metadata([metadata_lines[i] for i in item])

def copy(self) -> Self:
"""Get an independent copy of spectrum"""
Expand Down

0 comments on commit 87f32a0

Please sign in to comment.