Repository navigation
Preserve custom CHECKSUM and DATASUM comments on flush in update mode - #20825
pranjal9091 wants to merge 2 commits into
Conversation
|
Hi 👋 and thank you for your contribution! 🙏 This pull request is being closed automatically - but don't worry, we may re-open it if you carefully follow these instructions. Join the astropy slack using this invite link, head over to the #new-contributor-requests channel, and introduce yourself with a post that includes:
We strongly encourage contributions from people that use astropy or actively develop related scientific Python packages. We look forward to hearing from you and growing the Astropy community! Notes for maintainersIf you know this is a genuine user and the PR is is compliance with the AI policy, you may re-open this straight away. After two successful merged pull requests, the user will be added to the allowlist and future PRs will no longer be closed automatically. This user has not made any pull requests to this repository prior to this one. In addition, here are some statistics on the user's activity on GitHub:
|
|
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.
|
|
Hi @saimn, I noticed that This PR fixes #20789 by preserving custom CHECKSUM and DATASUM comments on flush in update mode. It includes unit tests in Could you please take a look and reopen when you have a chance? Thank you! |
Description
When a FITS file with existing
CHECKSUMandDATASUMcards is modified in update mode,_update_checksum()previously calledself.add_checksum()with no arguments. This causedwhento default toNone, silently replacing any custom comments on the cards with Astropy's default timestamp string ("HDU checksum updated ..."/"data unit checksum updated ...").This PR:
_update_checksum()to preserve existing custom comments onCHECKSUMandDATASUMcards (comments that do not start with the default timestamp prefix). Default timestamp comments continue to be refreshed with the current timestamp as before.add_checksum()andadd_datasum()to record and preserve user-suppliedwhenvalues, and adds an optionaldatasum_whenparameter toadd_checksum()allowing independent comments onDATASUMandCHECKSUM.test_checksum.pycovering both explicitadd_checksum(when=...)calls and automatic checksum recalculation on modified data in update mode.docs/changes/io.fits/20825.bugfix.rst.Fixes #20789
AI Disclosure
I used an AI assistant while investigating the codebase and drafting the initial test structure. I have reviewed, adapted, and verified all changes and tests locally.