Don't log when passed unit matches FITS BUNIT#19389
Open
m4cd4r4 wants to merge 6 commits intoastropy:mainfrom
Open
Don't log when passed unit matches FITS BUNIT#19389m4cd4r4 wants to merge 6 commits intoastropy:mainfrom
m4cd4r4 wants to merge 6 commits intoastropy:mainfrom
Conversation
Contributor
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
Member
|
Probably need regression test. |
Author
mwcraig
requested changes
Mar 23, 2026
astropy/nddata/ccddata.py
Outdated
| fits_unit_parsed = u.Unit(fits_unit_string) | ||
| except ValueError: | ||
| fits_unit_parsed = None | ||
| if fits_unit_parsed is None or fits_unit_parsed != u.Unit(unit): |
Member
There was a problem hiding this comment.
I would prefer a comparison of the string units as in #18678 rather than trying to parse the unit. There are some "valid" fit unit strings that do not immediately translate into astropy units.
Author
|
Done - switched to |
Member
Co-authored-by: Evan Warnock <176846909+Warnocke@users.noreply.github.com>
34c476d to
f72e2f8
Compare
Author
|
Done - rebased onto main and added @Warnocke as co-author on the last commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Description
Don't log when passed unit matches FITS BUNIT
CCDData.readlogs an info message whenever aunitargument is passed alongside a FITS file that has aBUNITheader, even when they match. This is noisy when users explicitly pass the unit to confirm what's already in the file.The log now only fires when the two units actually differ.
Fixes #13539