diff --git a/autonerves/fitsable.py b/autonerves/fitsable.py index a1ae1f8..505ecf6 100644 --- a/autonerves/fitsable.py +++ b/autonerves/fitsable.py @@ -135,9 +135,9 @@ def hdu_list_for_output_from( # Convert enum to its string value if needed key_str = key.value if isinstance(key, Enum) else key try: - header.append((key_str, value, [""])) + header.append((key_str, value, "")) except ValueError: - header.append((key_str, float(value), [""])) + header.append((key_str, float(value), "")) stamp_small_datasets_regime(header) diff --git a/test_autonerves/files/array_out.fits b/test_autonerves/files/array_out.fits index 85cddd5..cf72155 100644 Binary files a/test_autonerves/files/array_out.fits and b/test_autonerves/files/array_out.fits differ diff --git a/test_autonerves/test_fitsable.py b/test_autonerves/test_fitsable.py index 27f78f7..58409ff 100644 --- a/test_autonerves/test_fitsable.py +++ b/test_autonerves/test_fitsable.py @@ -222,3 +222,27 @@ def test__stamp_key_stays_within_the_fits_standard_card_limit(): # would quietly un-fix the interferometer case. Pin the ceiling. assert len(KEY) <= 8 assert KEY == KEY.upper() + + +def test__header_dict_cards_carry_no_junk_comment(tmp_path): + # Regression: the comment was passed as the LIST [""], which astropy does not + # reject -- it str()s it -- so every header_dict card on disk read + # `PIXSCAY = 0.1 / ['']`. Cosmetic, but it shipped in every Imaging dataset + # the stack wrote and rendered for anyone opening a PyAuto FITS in DS9 or + # astropy. Pin the comment empty so the wart cannot come back. + fitsable.output_to_fits( + np.ones((4, 4)), + file_path=tmp_path / "h.fits", + header_dict={"PIXSCAY": 0.1, "ORIGINY": 0.0}, + ) + + header = fits.open(tmp_path / "h.fits")[0].header + + assert header["PIXSCAY"] == 0.1 + assert header.comments["PIXSCAY"] == "" + assert header.comments["ORIGINY"] == "" + assert "[" not in str(header.cards["PIXSCAY"]) + + # The regime stamp keeps its real comment -- this is about junk, not about + # removing every comment. + assert fitsable.SMALL_DATASETS_HEADER_COMMENT in str(header.cards[KEY])