pydata / pydata/xarray

Indexes not displayed in DataTree repr

Open
#10,578 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-DataTree topic-html-repr
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
Image
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
Image
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.