From 69ad345097b11d703e374d551e27726c3b1d7861 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Tue, 7 Mar 2023 13:34:00 -0500 Subject: [PATCH] Fix spectral slice handling in tuple input case (e.g. crop) --- specutils/spectra/spectrum1d.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/specutils/spectra/spectrum1d.py b/specutils/spectra/spectrum1d.py index 0d1e0c0e1..3878a8798 100644 --- a/specutils/spectra/spectrum1d.py +++ b/specutils/spectra/spectrum1d.py @@ -396,7 +396,10 @@ def __getitem__(self, item): "values is not currently allowed, " "please use a slice.") spec_item = slice(spec_item, spec_item+1, None) - item = item[:-1] + (spec_item,) + # We have to hack around updating this tuple entry + item = list(item) + item[self.spectral_axis_index] = spec_item + item = tuple(item) else: # Slicing on less than the full number of axes means we want # to keep the whole spectral axis