We never explicitly added support for iterating over Spectra objects, but it is a reasonable thing to want to do and confusingly it "works" in a buggy way instead of just crashing or actually working. e.g.
for i, sp in enumerate(spectra[0:3]):
print(i, len(sp), np.array(sp.fibermap['TARGETID']))
i.e. it iterates over the objects as requested, returning length=1 Spectra objects, but then it continues iterating returning length=0 objects instead of exiting the iteration.
I think it is reasonable for the iterator to return length=1 Spectra objects instead of inventing another Spectrum class for containing a single spectrum, but the iterator should stop on its own.
Thanks to Charlie Tolley for noticing and reporting the problem.
We never explicitly added support for iterating over Spectra objects, but it is a reasonable thing to want to do and confusingly it "works" in a buggy way instead of just crashing or actually working. e.g.
Result
i.e. it iterates over the objects as requested, returning length=1 Spectra objects, but then it continues iterating returning length=0 objects instead of exiting the iteration.
I think it is reasonable for the iterator to return length=1 Spectra objects instead of inventing another Spectrum class for containing a single spectrum, but the iterator should stop on its own.
Thanks to Charlie Tolley for noticing and reporting the problem.