Skip to content

BUG: avoid mutation of shape attibutes (modeling, 2/2) - #19152

Merged
pllim merged 2 commits into
astropy:mainfrom
neutrinoceros:modeling/19126-2
Jan 14, 2026
Merged

pllim merged 2 commits into
astropy:mainfrom
neutrinoceros:modeling/19126-2

Conversation

@neutrinoceros

Copy link
Copy Markdown
Contributor

Description

This is a continuation of #19129, originated in #19150. I'm porting it to main so it can get its own review and backport cycle.
Commits are from @pllim and @mhvk, but I'm happy to endorse them.

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

pllim and others added 2 commits January 14, 2026 11:20
Avoid setting .shape in test_models.py
Co-authored-by: Marten van Kerkwijk <[email protected]>
@github-actions

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.

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

Looks all good to me, thanks!

z = gauss2d(x, y)
w = np.ones(x.size)
w.shape = x.shape
w = np.ones(x.shape)

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.

Nice catch!

@pllim
pllim merged commit 108d07d into astropy:main Jan 14, 2026
47 of 48 checks passed
@pllim

pllim commented Jan 14, 2026

Copy link
Copy Markdown
Member

Thanks, all!

meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Jan 14, 2026
@neutrinoceros
neutrinoceros deleted the modeling/19126-2 branch January 14, 2026 16:29
pllim added a commit that referenced this pull request Jan 14, 2026
…152-on-v7.2.x

Backport PR #19152 on branch v7.2.x (BUG: avoid mutation of shape attibutes (modeling, 2/2))
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