Skip to content

Indexes not displayed in DataTree repr #10578

@TomNicholas

Description

@TomNicholas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    To do

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions