Skip to content

BUG: avoid deprecated shape mutating APIs (coordinates) - #19127

Merged
mhvk merged 1 commit into
astropy:mainfrom
neutrinoceros:coordinates/19126
Jan 16, 2026
Merged

mhvk merged 1 commit into
astropy:mainfrom
neutrinoceros:coordinates/19126

Conversation

@neutrinoceros

Copy link
Copy Markdown
Contributor

Description

ref #19126

  • 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 commented Jan 8, 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.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

docs failures are unrelated #19134

@neutrinoceros
neutrinoceros marked this pull request as ready for review January 8, 2026 13:58
@neutrinoceros
neutrinoceros force-pushed the coordinates/19126 branch 2 times, most recently from 3298dc3 to 509d8fd Compare January 14, 2026 22:21
@neutrinoceros neutrinoceros changed the title BUG: avoid mutation of shape attibutes (coordinates) BUG: avoid deprecated shape mutating APIs (coordinates) Jan 14, 2026
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

@pllim @mhvk This seems sufficient to fix the 2 related failures seen directly within coordinates' test suite. Hopefully this should also fix other impacted tests.

@pllim

pllim commented Jan 15, 2026

Copy link
Copy Markdown
Member

I still see other coordinates stuff emitting warnings. Will that be a separate PR?

@neutrinoceros

neutrinoceros commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Looks to me that these a really upstream issues, so yeah, definitely a separate PR.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

for reference: brandon-rhodes/python-jplephem#63

@pllim
pllim requested a review from mhvk January 15, 2026 16:31

@mhvk mhvk 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.

The first change is good, but I think for anything inheriting from ShapedLikNDArray, we should let the deprecations percolate up (as we implicitly do for Quantity).

oldshape = self.shape
for component in self.components:
val = getattr(self, component)
if val.size > 1:

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.

Shouldn't we just let the deprecations appear? I think eventually we want to just follow numpy and no longer allow direct setting of shape. I.e., here adjust the tests to expect deprecation warnings for numpy >=2.5.

@neutrinoceros neutrinoceros Jan 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree. I was actually thinking we could do this as a second phase, after CI is back to green, so other devs don't get accustomed to ignoring failures in allowed-failures, as it's not immediately obvious to me exactly how to do this properly, and we probably want to get it right the first time. WDYT ?

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.

Yes, that makes sense - I created a sub-issue #19168 in your over-view issue #19126. We can then separately decide whether or not to backport that. Let's merge this PR then to get things back to green.

@mhvk mhvk 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.

Approving now after we decided to separate out letting shape setting deprecations perculate up.

@mhvk
mhvk merged commit 01f8c90 into astropy:main Jan 16, 2026
31 of 33 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Jan 16, 2026
@neutrinoceros
neutrinoceros deleted the coordinates/19126 branch January 16, 2026 14:49
pllim added a commit that referenced this pull request Jan 16, 2026
osasisorae added a commit to osasisorae/astropy that referenced this pull request Jan 18, 2026
Replace .shape = assignments with .resize(new_shape, refcheck=False)
to maintain compatibility with NumPy 2.5+ while preserving all
existing functionality.

Changes:
- coordinates/solar_system.py: Fix body_posvel_bary shape assignment
- coordinates/representation/base.py: Fix component and differential shape assignments
- time/core.py: Fix val shape assignments with error recovery
- io/ascii/ecsv.py: Fix column shape assignments (2 occurrences)
- io/fits/util.py: Fix array reshape in NumPy < 2.5 branch
- io/fits/fitsrec.py: Fix field shape assignment
- uncertainty/core.py: Fix structured array shape assignment
- Test files: Update compressed FITS and image tests

All fixes use refcheck=False parameter for Astropy's array views
and follow patterns from merged PRs astropy#19127-astropy#19152.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants