Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix read_spectra skipping exp_fibermap #2137

Merged
merged 1 commit into from
Nov 7, 2023
Merged

fix read_spectra skipping exp_fibermap #2137

merged 1 commit into from
Nov 7, 2023

Conversation

sbailey
Copy link
Contributor

@sbailey sbailey commented Nov 3, 2023

This PR is a followup to #2052, fixing a bug with read_spectra(..., skip_hdus=['EXP_FIBERMAP', ...])

The original code looping over HDUs had

...
elif name == "EXP_FIBERMAP" and name not in skip_hdus:
    ...
elif ...

The problem was that if "EXP_FIBERMAP" was in skip_hdus, then it would continue down the elif chain and eventually get interpreted as a catchall user-provided "BAND_EXTRANAME" image HDU, which would then trip on reading a table as an image.

The fix is

...
elif name == "EXP_FIBERMAP":
    if name not in skip_hdus:
        ...
elif ...

so that if it finds "EXP_FIBERMAP" but it is in skip_hdus then it will stop checking rather than continuing to try to parse the name as meaning other things. I applied that same pattern to all other cases of known HDU names that might be in the skip_hdu list.

This includes a unit test that would have caught the original problem, but now passes.

@dirkscholte I'm pretty sure that I introduced this bug when updating your PR #2052, but if you could double-check my fix here I would appreciate it. Thanks.

@sbailey sbailey added the bug label Nov 3, 2023
@sbailey sbailey requested a review from dirkscholte November 3, 2023 20:45
Copy link
Member

@dirkscholte dirkscholte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sbailey. This makes a lot of sense! In the earliest version I made of this (might not be the version that started this pull request) I purposefully broke out some functionality because I had a similar issue. Thanks for fixing this :)

@sbailey sbailey merged commit ed313eb into main Nov 7, 2023
24 checks passed
@sbailey sbailey deleted the read_spectra branch November 7, 2023 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants