Skip to content

temporarily silence shape assignment warnings raised in netCDF4#11146

Merged
keewis merged 8 commits into
pydata:mainfrom
keewis:shape-assignment
Feb 11, 2026
Merged

temporarily silence shape assignment warnings raised in netCDF4#11146
keewis merged 8 commits into
pydata:mainfrom
keewis:shape-assignment

Conversation

@keewis

@keewis keewis commented Feb 7, 2026

Copy link
Copy Markdown
Collaborator

Apparently, numpy has decided to deprecate assignments like x[...] = y. We can replace this with

slices = (slice(None),) * y.ndim
x[slices] = y

@keewis keewis changed the title replace ellipsis assignment with an explicit slice replace ellipsis assignment with explicit slices Feb 7, 2026
@keewis keewis added the run-upstream Run upstream CI label Feb 8, 2026

@jsignell jsignell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gross but good catch! It looks like there is another assignment like this in _copy_with_dtype

@keewis

keewis commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator Author

I might have totally misunderstood what they deprecated. It appears that was x.shape = new_shape, not ellipsis assignment. However, that means that the warning would actually be emitted in netcdf4 code, so I'm trying to create a reproducer without using xarray code.

Edit: see Unidata/netcdf4-python#1468

@keewis

keewis commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator Author

should be good for another round of reviews (I'm not at all sure this is the best way to ignore the warning) and merging

@keewis keewis changed the title replace ellipsis assignment with explicit slices temporarily silence shape assignment warnings raised in netCDF4 Feb 11, 2026

@jsignell jsignell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@keewis

keewis commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator Author

let's merge, then!

@keewis keewis merged commit 697fd15 into pydata:main Feb 11, 2026
49 of 85 checks passed
@keewis keewis deleted the shape-assignment branch February 11, 2026 19:18
@doronbehar doronbehar mentioned this pull request Feb 20, 2026
2 tasks
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