Skip to content

Fix slicing of GroupData created from arrays - #20514

Merged
saimn merged 2 commits into
astropy:mainfrom
awss1i:fix-groupdata-slicing
Oct 19, 2026
Merged

saimn merged 2 commits into
astropy:mainfrom
awss1i:fix-groupdata-slicing

Conversation

@awss1i

@awss1i awss1i commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Description

Slicing a GroupData created from arrays, rather than read from a file, raised TypeError: 'NoneType' object is not subscriptable. GroupData.__new__ never pointed its columns at the new fields, and FITS_rec.__getitem__ reads those references when slicing. It now sets them the same way FITS_rec.from_columns does.

#2748 hit this through repr() with more than 1000 groups. That no longer fails, because numpy converts to a plain array before printing, but slicing the same data still did.

The scaled case is only checked in memory, because writing scaled in-memory group data is a separate bug (#2751).

Fixes #6688
Fixes #2748

AI Disclosure

I chose this issue, directed the work, and reviewed the fix, the test and the reproductions before opening this PR. Under my direction, Claude Code (Claude Opus 5.5) traced the cause, wrote the fix, the test and the changelog entry, drafted this description, and ran the reproductions and the io.fits tests on a local build.

  • I certify that I am human and that I take full responsibility for this pull request including all interactions with reviewers.

Merge method

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@awss1i
awss1i requested a review from saimn as a code owner October 1, 2026 07:48
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
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.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@pllim pllim added this to the v8.1.0 milestone Oct 1, 2026
@awss1i
awss1i force-pushed the fix-groupdata-slicing branch from 8e27003 to 83de5ed Compare October 2, 2026 18:23
@awss1i

awss1i commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

The test failures aren't from this change. Every failing job stops on the config tests importing astropy.extern.configobj, which was broken at the old base c55a2b2 and is fixed on main. I rebased onto main. Could a maintainer approve the new run?

@saimn saimn modified the milestones: v8.1.0, v7.2.4 Oct 19, 2026
@saimn saimn added backport-v7.2.x on-merge: backport to v7.2.x backport-v8.0.x on-merge: backport to v8.0.x labels Oct 19, 2026

@saimn saimn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@saimn
saimn merged commit a0380a5 into astropy:main Oct 19, 2026
56 of 59 checks passed
@pllim

pllim commented Oct 19, 2026

Copy link
Copy Markdown
Member

@astrofrog , what do you think? Exclude from contributor list?

Last 24 hours Last 7 days
Pull requests opened 5 51
Issues opened 0 33

@awss1i

awss1i commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@astrofrog , what do you think? Exclude from contributor list?

Last 24 hours Last 7 days
Pull requests opened 5 51
Issues opened 0 33

Hey @pllim , just wanted to jump in and clarify nothing here is automated or running on a bot loop. I’m a real person manually selecting issues, directing the agent's focus, running/verifying the reproductions, and reviewing every diff before opening a PR. Im real haha, I've just been working alot in my free time contributing to just about anything i find cool, and do plan to continue on astropy. For reference i'm an AI systems engineer with a focus on security research and debugging. I completely respect whatever your team decide, just figured I'd let you know.

pllim added a commit that referenced this pull request Oct 19, 2026
…514-on-v7.2.x

Backport PR #20514 on branch v7.2.x (Fix slicing of GroupData created from arrays)
pllim added a commit that referenced this pull request Oct 19, 2026
…514-on-v8.0.x

Backport PR #20514 on branch v8.0.x (Fix slicing of GroupData created from arrays)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v7.2.x on-merge: backport to v7.2.x backport-v8.0.x on-merge: backport to v8.0.x io.fits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slicing GroupsHDU astropy.io.fits: repr() error in GroupData object with more than 1000 groups

3 participants