Skip to content

fix: stop writing the literal comment [''] on every header_dict FITS card - #155

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/fits-header-comment-literal-list
Aug 22, 2026
Merged

fix: stop writing the literal comment [''] on every header_dict FITS card#155
Jammy2211 merged 1 commit into
mainfrom
claude/fits-header-comment-literal-list

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

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 / ['']
PIXSCAX =                  0.1 / ['']
ORIGINY =                  0.0 / ['']
ORIGINX =                  0.0 / ['']

Every Imaging dataset 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 plain PIXSCAY = 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/ORIGINY are not self-describing to an outside reader and the slot is already there. Not doing it, deliberately.

autonerves receives an opaque header_dict and does not know the key vocabulary — PIXSCAY/PIXSCAX/ORIGINY/ORIGINX are autoarray's Mask2DKeys. 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 to header_dict's shape, not a rider on this.

Test Plan

  • python -m pytest test_autonerves/166 passed
  • Green and byte-identical with PYAUTO_SMALL_DATASETS=1 exported and unset
  • On-disk card verified: A = 1 with no comment; the SMALLDAT stamp keeps its real comment, so this removes junk rather than all comments
  • Regression test pins the comment empty and asserts no [ in the rendered card
  • Fixture rewrite verified byte-stable across repeated runs (identical md5)

Fixture refresh

test_autonerves/files/array_out.fits is 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_DATASETS for 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

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.
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 22, 2026 — with Claude
@Jammy2211
Jammy2211 merged commit 0ecefa0 into main Aug 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants