xbudget.display

Human-friendly renderings of an xbudget recipe.

A recipe is a deeply nested provenance tree. Printed as raw JSON it is almost unreadable; what a user actually wants is the shape — which terms sum into which, what operation builds each, and (after a run) what each term is called in the dataset. This module renders the typed tree (xbudget.nodes, via xbudget.parse.parse_budgets()) rather than the raw dict, so it shows real semantics (operator badges, scalars vs. diagnostics) and inherits the parser’s tolerance of the malformed/placeholder nodes real recipes carry.

Two renderings, one walker:

  • _repr_html_ — a collapsible tree of nested <details>/<summary> elements (native HTML5, no JavaScript), styled after xarray’s Dataset repr so it feels at home in the same notebooks. Click an arrow to expand a level.

  • __repr__ — an indented ├─/└─ ASCII tree, for terminals and any context that does not render HTML.

Entry points:

  • show_recipe() — inspect a recipe offline (no dataset). Returns a small displayable object; show_recipe(recipe, "heat") scopes to one budget.

  • xbudget.query.BudgetQuery._repr_html_() — the same tree, but annotated with each term’s resolved variable name and with unmaterialized terms greyed out, so displaying a query in a notebook shows structure and run state.

Functions

render_budgets_html(budgets[, resolve, header])

Render {name: Budget} as a collapsible HTML tree.

render_budgets_text(budgets[, resolve, header])

Render {name: Budget} as an indented ASCII tree.

show_recipe(recipe[, budget])

Display a recipe as a collapsible tree.