Skip to content

docs(v1): fix §11 MultiIndex-level projection example#856

Merged
FBumann merged 1 commit into
feat/arithmetic-conventionfrom
docs/convention-s11-fix
Jul 20, 2026
Merged

docs(v1): fix §11 MultiIndex-level projection example#856
FBumann merged 1 commit into
feat/arithmetic-conventionfrom
docs/convention-s11-fix

Conversation

@FBumann

@FBumann FBumann commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Fixes a broken example in the v1 spec, found while polishing the migration guide (companion to #855). Part of the #717 spec-cleanup.

Note

The following was generated by AI.

§11 example can't run under v1. The MultiIndex-level projection fix read:

weights.sel(period=expr.indexes["snapshot"].get_level_values("period"))

Verified on the branch: v1 rejects a first-class pd.MultiIndex dimension at construction (add_variables raises ValueError: ... does not support ... reset_index('snapshot')), so snapshot is a flat dim with period/timestep as aux coords and .indexes["snapshot"] is a flat index — .get_level_values(...) fails. Replaced with the working aux-coord mapping (tested, coeffs [1,1,1,10,10,10]):

# weights: Series indexed by `period`; expr: indexed by `snapshot`
w = xr.DataArray(weights.loc[expr.coords["period"].values].to_numpy(), dims="snapshot")
weighted = expr * w   # one term per snapshot, weighted by its period

The example now shows the full flow (map onto snapshot, then multiply) rather than dangling an unused intermediate.

Placement note. Also recorded in open-items.md that convention.md graduates into the rendered Sphinx docs at the 1.0 reframe (add myst-parser, toctree, internal cross-refs). Until then it stays a design-record linked by URL: the §1–§13 rules are permanent, but the transitional "v1-vs-legacy" framing would only be re-done, so rendering now is wasted effort. This reflects the repo's own Stage-3 plan (goals.md splits permanent design goals from temporary transitioning goals).

…raduation

The §11 example used `expr.indexes["snapshot"].get_level_values("period")`,
which cannot run under v1: v1 rejects a first-class `pd.MultiIndex` dimension
at construction, so `snapshot` is a flat dim with `period`/`timestep` as aux
coords and `.indexes["snapshot"]` is a flat index, not a MultiIndex. Replace it
with the working aux-coord mapping (verified on the branch) and add a one-line
note on the flat representation.

Also record in open-items.md that convention.md graduates into the rendered
Sphinx docs at the 1.0 reframe (add myst-parser, toctree, internal cross-refs);
until then it stays a design-record linked by URL — the rules are permanent but
the transitional framing would only be re-done, so rendering now is wasted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FBumann
FBumann force-pushed the docs/convention-s11-fix branch from 5afbb35 to 004ebcc Compare July 20, 2026 09:13
@FBumann
FBumann merged commit 921392a into feat/arithmetic-convention Jul 20, 2026
2 checks passed
@FBumann
FBumann deleted the docs/convention-s11-fix branch July 20, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant