Skip to content

Conversation

@eshort0401
Copy link

Forbids pathlike coordinate names as a temporary solution before #9485 is fully resolved. This PR is almost the same as the coordinate name checking part of @TomNicholas's PR #9492 from 2024; not sure why this wasn't merged, and happy to update whats-new.rst authorship if appropriate! The main difference between this PR and #9492 is a targeted error message when coordinate keys are being checked. Code like

from xarray import DataTree, Dataset
tree = DataTree(Dataset(coords={'x': 0}), children={'child': DataTree()})
tree.coords['/child/y'] = 2

will now produce

ValueError: Given coordinate names contain the '/' character: ['/child/y']. Accessing the coordinates of other nodes in the tree is not yet supported here. Retrieve the other node first, then access its coordinates.

I've also amended the DataTree.coords and DataTree.data_vars docstrings to communicate these currently only access the coordinates and variables of the given node, respectively.

Notes

This PR follows from discussion in #11001.

@github-actions github-actions bot added the topic-DataTree Related to the implementation of a DataTree class label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-DataTree Related to the implementation of a DataTree class

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant