docs(notebooks): run example notebooks under the v1 convention#833
Merged
Merged
Conversation
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
force-pushed
the
docs/notebooks-v1-convention
branch
from
July 16, 2026 07:21
85be35a to
39ba3ef
Compare
FBumann
marked this pull request as ready for review
July 16, 2026 07:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 transportmaskwas a raw(6, 6)numpy array; under v1 that can't be paired unambiguously with the(from, to)dims, so it's now a labelledDataArray.creating-expressions— the "first object determines the coordinates" positional example now raises. The notebook shows theValueErrorand resolves it withjoin="outer"; the.loc[:4] + .loc[5:]positional trick became an explicitjoin="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_coordsor an explicitjoin=). Thejoinwalkthrough is kept; the summary table now reflects v1 (default raises;outer/left/rightfill 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 arenbsphinx: {execute: never}; their model-building code was verified v1-safe locally.solve-on-remotekeeps its committed outputs (it's excluded from thenbstripouthook).Verification
jupyter nbconvert --execute).nbstripoutpre-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