Skip to content

Warn when explicit dims rename tuple-style DataArray coords#11292

Open
officialasishkumar wants to merge 3 commits intopydata:mainfrom
officialasishkumar:warn-11234-ignored-coord-names
Open

Warn when explicit dims rename tuple-style DataArray coords#11292
officialasishkumar wants to merge 3 commits intopydata:mainfrom
officialasishkumar:warn-11234-ignored-coord-names

Conversation

@officialasishkumar
Copy link
Copy Markdown

Description

Warn when tuple-style coordinates are passed to DataArray(...) together with explicit dims= and their tuple names are silently ignored. This adds a user-facing warning for that case, targeted constructor tests, and a whats-new entry.

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
      Tools: Codex

Test plan

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest -o addopts= /tmp/xarray-wt-11234/xarray/tests/test_dataarray.py -k constructor_tuple_coords -q

Copy link
Copy Markdown
Member

@jsignell jsignell left a comment

Choose a reason for hiding this comment

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

This is a nice improvement. Thanks @officialasishkumar

@jsignell jsignell added the plan to merge Final call for comments label Apr 10, 2026
Comment thread xarray/core/dataarray.py
@officialasishkumar officialasishkumar force-pushed the warn-11234-ignored-coord-names branch from 9877f6c to d0cb208 Compare April 11, 2026 19:46
Comment thread xarray/tests/test_dataarray.py Outdated
Comment on lines +437 to +442
expected = DataArray(
data,
coords={"x": [0, 1], "y": [-1, -2, -3]},
dims=["x", "y"],
)
assert_identical(expected, actual)
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.

It would make more sense to have this test instantiate the DataArray using a different syntax from actual.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated this to build the expected result through Dataset instead of the same DataArray constructor path.

Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
@officialasishkumar officialasishkumar force-pushed the warn-11234-ignored-coord-names branch from d0cb208 to daa55e1 Compare April 16, 2026 14:22
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

Development

Successfully merging this pull request may close these issues.

Request a warning for when coord names are ignored when dims are specified

3 participants