Skip to content

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

Merged
headtr1ck merged 4 commits into
pydata:mainfrom
officialasishkumar:warn-11234-ignored-coord-names
Sep 29, 2026
Merged

headtr1ck merged 4 commits into
pydata:mainfrom
officialasishkumar:warn-11234-ignored-coord-names

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

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

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

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

@officialasishkumar
officialasishkumar force-pushed the warn-11234-ignored-coord-names branch from d0cb208 to daa55e1 Compare April 16, 2026 14:22
@headtr1ck
headtr1ck enabled auto-merge (squash) September 29, 2026 07:21
@headtr1ck
headtr1ck merged commit ede38e5 into pydata:main Sep 29, 2026
44 checks passed
TomNicholas added a commit that referenced this pull request Sep 29, 2026
* Update whats-new for v2026.09.0 release

- Rename the unreleased section to v2026.09.0 and add the release summary
  and contributor list
- Move entries for #11348, #11292, #11290 and #11239 that were merged into
  older release sections
- Add missing entries for #11552, #11521, #11486 and #11513
- Add missing PR links, fix the #11547 link and other markup
- Fix the documented default of the use_bottleneck option
- Add contributor names to the typos allow-list

* Mention plot.lines and last Python 3.11 release in whats-new
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