Skip to content

docs(notebooks): run example notebooks under the v1 convention#833

Merged
FBumann merged 1 commit into
feat/arithmetic-conventionfrom
docs/notebooks-v1-convention
Jul 16, 2026
Merged

docs(notebooks): run example notebooks under the v1 convention#833
FBumann merged 1 commit into
feat/arithmetic-conventionfrom
docs/notebooks-v1-convention

Conversation

@FBumann

@FBumann FBumann commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

TODO (author): write your intent and motivation here in your own words.

Note

The following content was generated by AI.

Stacked on #717. Opts every example notebook into the v1 arithmetic convention (linopy.options["semantics"] = "v1") and fixes the code that relied on legacy alignment, so the docs teach and run under v1.

Notebooks needing more than the opt-in

  • creating-variables — the transport mask was a raw (6, 6) numpy array; under v1 that can't be paired unambiguously with the (from, to) dims, so it's now a labelled DataArray.
  • creating-expressions — the "first object determines the coordinates" positional example now raises. The notebook shows the ValueError and resolves it with join="outer"; the .loc[:4] + .loc[5:] positional trick became an explicit join="override".
  • coordinate-alignment — the intro taught legacy superset-fill and same-shape positional alignment, both removed by v1. Rewrote it to teach label-based alignment (mismatches raise; resolve via .sel / .reindex / .assign_coords or an explicit join=). The join walkthrough is kept; the summary table now reflects v1 (default raises; outer/left/right fill non-overlapping slots with the operation's identity, verified against actual v1 output).

Remote notebooks (solve-on-oetc, solve-on-remote) carry the opt-in too. Both are nbsphinx: {execute: never}; their model-building code was verified v1-safe locally. solve-on-remote keeps its committed outputs (it's excluded from the nbstripout hook).

Verification
  • All 13 locally-runnable notebooks execute cleanly under v1 (jupyter nbconvert --execute).
  • Outputs stripped to match the nbstripout pre-commit hook; notebook metadata restored from the base so diffs are source-only.
  • ruff, nbstripout, and the other pre-commit hooks pass.

🤖 Generated with Claude Code

Opt every example notebook into the strict v1 arithmetic convention
(linopy.options["semantics"] = "v1") and fix the code that relied on
legacy alignment:

- creating-variables: wrap the transport mask in a labelled DataArray
  so the (6, 6) array pairs unambiguously with the (from, to) dims.
- creating-expressions: mismatched shared-dim labels now raise; show
  the error and resolve it with join="outer" / join="override".
- coordinate-alignment: rewrite the intro that taught legacy
  superset-fill and same-shape positional alignment to teach v1
  label-matching — mismatches raise and are resolved via
  .sel/.reindex/.assign_coords or an explicit join=. The join
  sections are kept; the summary table now reflects v1 defaults.

The two remote notebooks (solve-on-oetc, solve-on-remote) carry the
opt-in too; both are marked nbsphinx execute:never, and
solve-on-remote keeps its committed outputs (nbstripout-excluded).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FBumann
FBumann force-pushed the docs/notebooks-v1-convention branch from 85be35a to 39ba3ef Compare July 16, 2026 07:21
@FBumann
FBumann marked this pull request as ready for review July 16, 2026 07:24
@FBumann
FBumann merged commit 91c33c1 into feat/arithmetic-convention Jul 16, 2026
2 checks passed
@FBumann
FBumann deleted the docs/notebooks-v1-convention branch July 16, 2026 07:24
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