Skip to content

Raise UserWarning when rename creates a new dimension coord - #6999

Merged
benbovy merged 3 commits into
pydata:mainfrom
benbovy:add-warning-rename-dim-coord
Sep 27, 2022
Merged

benbovy merged 3 commits into
pydata:mainfrom
benbovy:add-warning-rename-dim-coord

Conversation

@benbovy

@benbovy benbovy commented Sep 6, 2022 •

Copy link
Copy Markdown
Member

Current implemented "fix": raise a UserWarning and suggest using swap_dims (*)

Alternatively, we could:

  • revert the breaking change (i.e., create the index again) and raise a DeprecationWarning instead
  • raise an error instead of a warning

I don't have strong opinions on this, I'm happy to implement another alternative. The downside of reverting the breaking change now is that unfortunately it will introduce a breaking change in the next release., while workarounds are pretty straightforward.

(*) from #6607 (comment), doing ds.set_coords(['lon']).rename(x='lon').set_index(lon='lon') is working too. With #6971, .set_xindex('lon') could work as well.

@benbovy benbovy mentioned this pull request Sep 23, 2022
@headtr1ck

Copy link
Copy Markdown
Collaborator

looks good to me

@Illviljan Illviljan added the plan to merge Final call for comments label Sep 24, 2022
@benbovy

benbovy commented Sep 27, 2022

Copy link
Copy Markdown
Member Author

Thanks @headtr1ck, ok let's merge this.

@benbovy
benbovy merged commit 45c0a11 into pydata:main Sep 27, 2022
@benbovy
benbovy deleted the add-warning-rename-dim-coord branch December 8, 2022 09:38
johnomotani added a commit to boutproject/xBOUT that referenced this pull request Jan 20, 2023
xarray behaviour changed, see pydata/xarray#6999
and links from there.
davidgegiya added a commit to davidgegiya/agent-orchestrator that referenced this pull request Nov 8, 2026
… an index

Pin 1f4be33365573da19a684dd7f2fc97ace5d28710 and its regression selectors for reproducible runs.

Source: pydata/xarray#6999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan to merge Final call for comments

Projects

None yet

3 participants