Skip to content

raise an error for assign_coords({Hashable: xr.Coordinates}) #10194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dcherian opened this issue Mar 31, 2025 · 1 comment
Open

raise an error for assign_coords({Hashable: xr.Coordinates}) #10194

dcherian opened this issue Mar 31, 2025 · 1 comment

Comments

@dcherian
Copy link
Contributor

dcherian commented Mar 31, 2025

What happened?

This works but is wrong.

import xarray as xr
from xarray.indexes import RangeIndex

ds = xr.Dataset({"foo": ("x", [1, 2, 3])})
coords = xr.Coordinates.from_xindex(RangeIndex.arange("x", "x", 1.5, 4.5, 1.0))
ds.assign_coords({"x": coords})

What did you expect to happen?

We should error and tell the user to use ds.assign_coords(coords) instead

xref efe3e81#r2019841034

@benbovy
Copy link
Member

benbovy commented Apr 3, 2025

Yes I agree we can easily detect when such case happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants