BUG: io.fits: improve error for FITS tables with more than 999 columns#19545
Open
FazeelUsmani wants to merge 3 commits into
Open
BUG: io.fits: improve error for FITS tables with more than 999 columns#19545FazeelUsmani wants to merge 3 commits into
FazeelUsmani wants to merge 3 commits into
Conversation
…olumns FITS tables cap at 999 columns by the FITS standard: indexed per-column keywords like TTYPEn / TFORMn must fit within the 8-character keyword limit, so n is restricted to 1-3 digits. Previously this surfaced as a cryptic late-stage VerifyError on the TFIELDS card at write time. The check now lives in ColDefs._validate_column_count, called at the end of ColDefs.__init__ and before any mutation in ColDefs.add_col, so the failure fires at column-definition time across every construction path: Table.write(format='fits'), BinTableHDU.from_columns, raw ColDefs, coldefs + col, and add_col. The pre-mutation guard in add_col leaves the ColDefs untouched on failure rather than half-mutated. Fixes astropy#19236.
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.
|
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.
Fixes #19236.
Description
This PR improves the error raised for FITS tables with more than 999 columns.
Previously, this surfaced late as a cryptic
VerifyErrorduring write. This change addsColDefs._validate_column_count, called at the end ofColDefs.__init__and before mutation inColDefs.add_col, so the failure happens earlier with a clearValueError.Because the check lives in
ColDefs, it applies across the main construction paths, includingTable.write(format="fits"),BinTableHDU.from_columns, directColDefs(...),coldefs + col, andColDefs.add_col. Theadd_colpath validates before mutation, so a failed addition leaves the originalColDefsunchanged.Tests
Table.write(format="fits")BinTableHDU.from_columns, directColDefs(...),coldefs + col, andColDefs.add_col