Feature Request: First-class representation of nested attributes

Abierto
#11,240 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

Empieza rastreando las rutas de repr() y de la representación HTML de xarray en Jupyter; después, inspecciona cómo se muestran actualmente ds.attrs y los atributos de los grupos. Define el alcance de la representación antes de la implementación; el resultado debería hacer que los objetos y arrays profundamente anidados se vean estructurados, y que cualquier comportamiento expandible solicitado quede cubierto por pruebas de representación.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement topic-html-repr
Is your feature request related to a problem?

Formats such as Zarr store group attributes in JSON (e.g. .zattrs), so attributes can be deeply nested (objects and arrays). The current xarray APIs and built-in representations (e.g. repr(), HTML repr in Jupyter) typically expose attributes in a flat or single-level way. That makes it hard to inspect or document complex metadata in the IDE or in notebooks. Users either see a flattened view, truncated output, or have to manually traverse raw attribute dicts instead of seeing the structure xarray actually has at hand.

Xarray current HTML representation (only top-level attributes are shown, with full content):

Image
Describe the solution you'd like

First-class support for nested attributes in xarray’s APIs and/or representations, for example:

  • Repr / HTML repr: Optionally render nested attributes as an expandable/collapsible tree (or at least with clear indentation/structure) instead of a single-level or flattened dump, so users can see the full hierarchy in Jupyter and other environments that rely on xarray’s built-in repr.

The goal is that opening a dataset with rich nested metadata (e.g. from Zarr) feels natural in xarray: the repr and APIs should reflect that nesting rather than flattening or hiding it.

Describe alternatives you've considered
  • Manual traversal: Users can already walk ds.attrs (or group attrs) and pretty-print themselves. This doesn’t improve the default experience in Jupyter or the consistency of tooling.
  • Downstream-only handling: Some tools (e.g. Scientific Data Viewer) can render nested attributes in a tree view on the viewer side. That helps when using those tools but doesn’t improve the experience for users who only use xarray’s built-in repr or other consumers that follow xarray’s representation.
  • Leaving attributes as “opaque” dicts: Keeps implementation simple but under-serves users and formats (like Zarr) where nested metadata is the norm.

Example: Scientific Data Viewer nested representation of nested attributes with collapsible sections:

Image
Additional context
  • This would benefit anyone opening Zarr (or similar) datasets with rich .zattrs-style metadata in Jupyter or scripts.
  • Downstream projects (e.g. Scientific Data Viewer) could align their UIs with xarray’s representation for consistency when the same dataset is opened in xarray and in other tools.
  • Reference: Scientific Data Viewer – xarray and nested attributes (doc that motivated this request).
Lenguaje dominante
Python
Estrellas
4.2k
Forks
1.5k
Merge medio
2 d 20 h
PR fusionados (30 d)
70

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pydata/xarray

Todos los issues de pydata/xarray

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.