fix: stop writing the literal comment [''] on every header_dict FITS card - #155
Merged
Merged
Conversation
hdu_list_for_output_from passed a LIST, [""], as the FITS card comment. astropy
does not reject it -- it str()s it -- so every card written from a header_dict
landed on disk reading:
PIXSCAY = 0.1 / ['']
Every Imaging dataset the stack writes carries this on four cards (PIXSCAY,
PIXSCAX, ORIGINY, ORIGINX), and it renders for anyone opening a PyAuto FITS in
DS9, astropy or any external tool. Cosmetic, but it is output we hand to other
people and it reads as a serialization bug.
The intent was an empty comment; "" gives that, while the list gave the rendered
repr of a list. Verified on disk: the card becomes a plain `PIXSCAY = 0.1` with
no comment and no trailing slash, byte-size unchanged.
Deliberately NOT adding real per-key comments, which the prompt raised as an
option. autonerves receives an opaque header_dict and does not know the key
vocabulary -- PIXSCAY/ORIGINY are autoarray's Mask2DKeys. Hardcoding their
meanings here would couple the base serialization layer to a downstream key set,
which is the wrong direction. If descriptive comments are wanted, the caller
should be able to supply them, and that is a separate API change.
Nothing reads FITS comments anywhere in the stack -- every header consumer
indexes values by key name, verified during PyAutoNerves#153 -- so this changes
no behaviour. Pinned by a test so the wart cannot return.
The tracked fixture test_autonerves/files/array_out.fits is a test write target
whose bytes change with the comment; refreshed. Verified the rewrite is
byte-stable across repeated runs and identical with PYAUTO_SMALL_DATASETS
exported and unset, which the autouse conftest fixture from #154 guarantees.
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.
Summary
hdu_list_for_output_frompassed a list,[""], as the FITS card comment. astropy does not reject it — itstr()s it — so every card written from aheader_dictlanded on disk reading:Every
Imagingdataset the stack writes carries this on four cards, and it renders for anyone opening a PyAuto FITS in DS9, astropy, or any external tool. Cosmetic, but it is output we hand to other people, and it reads as a serialization bug.The intent was clearly an empty comment.
""gives that; the list gave the rendered repr of a list. Verified on disk — the card becomes a plainPIXSCAY = 0.1, no comment, no trailing slash, byte-size unchanged.Found while implementing the regime stamp (#153/#154) and deliberately left out of that change so a cosmetic fix did not ride along with a behavioural one.
API Changes
None — internal changes only.Nothing reads FITS comments anywhere in the stack — every header consumer indexes values by key name, verified across PyAutoArray, PyAutoGalaxy, PyAutoLens and the workspaces during #153. Values, keys, and card order are untouched.
A decision taken explicitly
The prompt raised adding real per-key comments, since
PIXSCAY/ORIGINYare not self-describing to an outside reader and the slot is already there. Not doing it, deliberately.autonervesreceives an opaqueheader_dictand does not know the key vocabulary —PIXSCAY/PIXSCAX/ORIGINY/ORIGINXare autoarray'sMask2DKeys. Hardcoding their meanings in the base serialization layer would couple it to a downstream key set, which is the wrong direction for the dependency. If descriptive comments are wanted, the caller should be able to supply them — that is a separate API change toheader_dict's shape, not a rider on this.Test Plan
python -m pytest test_autonerves/— 166 passedPYAUTO_SMALL_DATASETS=1exported and unsetA = 1with no comment; theSMALLDATstamp keeps its real comment, so this removes junk rather than all comments[in the rendered cardFixture refresh
test_autonerves/files/array_out.fitsis a test write target — the suite rewrites it every run — so its committed bytes change with the comment. Refreshed here.The autouse conftest fixture added in #154 pins
PYAUTO_SMALL_DATASETSfor the suite, so this rewrite is deterministic regardless of the shell it runs in; confirmed by getting identical bytes with the variable exported and unset.Generated by the PyAutoLabs agent workflow.
Generated by Claude Code