Skip to content

Fix bug when slicing a table with a multi-col index - #15

Closed
taldcroft wants to merge 1 commit into
table-callable-index-locfrom
table-fix-duplicate-indices-when-slicing
Closed

taldcroft wants to merge 1 commit into
table-callable-index-locfrom
table-fix-duplicate-indices-when-slicing

Conversation

@taldcroft

@taldcroft taldcroft commented Oct 7, 2025 •

Copy link
Copy Markdown
Owner

Description

This pull request is to fix a bug when slicing a table that has a multi-column index.

In Table._new_from_slice, the line newcol = col.info.slice_indices(newcol, slice_, len(col))
makes a new independent index in each column for a multi-column index. This causes confusion later in Table.indices since that property checks for object uniqueness of each index. The root cause of making new independent indices should be fixed but this is not so easy. Since this is a less-common case, for now we do a post-facto fix of simply forcing indices to be one object, namely the first instance encountered in processing, keyed by id.

  • 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.

@github-actions github-actions Bot added the table label Oct 7, 2025
@github-actions

github-actions Bot commented Oct 7, 2025

Copy link
Copy Markdown

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.

@taldcroft
taldcroft force-pushed the table-fix-duplicate-indices-when-slicing branch from c5f557b to 6794405 Compare October 8, 2025 09:35
@taldcroft taldcroft closed this Oct 8, 2025
@taldcroft
taldcroft deleted the table-fix-duplicate-indices-when-slicing branch October 8, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant