Indexes not displayed in DataTree repr
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What happened?
DataTree objects carry .indexes, but do not display them. This used to be more of an implementation detail but is more important now that we actually allow people to change these objects easily.
I also notice that indexes are currently displayed in Dataset's HTML repr but not the printable repr. Should we fix that?
What did you expect to happen?
The indexes to be displayed the same way that they are for Dataset and DataArray.
Indexes can also be "inherited" from parent nodes in the tree, so we should also display that information too, like how we already do for coordinate variables.
Minimal Complete Verifiable Example
In a jupyter notebook
import xarray as xr
ds = xr.Dataset(coords={"x": ("x", [0, 1])})
ds
print(ds)
<xarray.Dataset> Size: 16B
Dimensions: (x: 2)
Coordinates:
* x (x) int64 16B 0 1
Data variables:
*empty*
dt = xr.DataTree.from_dict({"/": ds})
dt
print(dt)
<xarray.DataTree>
Group: /
Dimensions: (x: 2)
Coordinates:
* x (x) int64 16B 0 1
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
Anything else we need to know?
FYI @aladinor @shoyer @dcherian @benbovy @keewis
Environment
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided Dataset and DataTree examples in a Jupyter notebook, then compare DataTree output with the existing Dataset and DataArray representations. The work is done when indexes appear in DataTree representations, including inherited indexes from parent nodes, consistently with coordinate-variable display.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100