Repository navigation
feat(language)!: a construct that reads the order of a dimension needs the dimension declared ordered - #793
Merged
Conversation
A dimension declares `ordered: true` where the order of its members is part of the model; the default is false. shift, sum_back, position(), a piecewise curve's `over:` and a type-2 set's `along:` read that order, and the loader refuses each along a dimension that is not ordered, naming the declaration to add. `ordered` is written only where true. Every example, test spec and docs block that steps along a dimension now declares it ordered; the generated pages, the schema and the golden output are regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WQi3Nh7wYqbniKdGm8MrGF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WQi3Nh7wYqbniKdGm8MrGF
Documentation build overview
58 files changed ·
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011a8N2JQdmmd1WhVCKN1a2A
… splitter writes it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011a8N2JQdmmd1WhVCKN1a2A
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CsaSWMofYqJiKmnSiPycV9
#834 gave examples/pypsa/security.yaml a period dimension; the regenerated fragment declares it ordered, as examples/pypsa.yaml does.
…h may add it but not withdraw it A patch restatement is compared as the schema reads both sides, so a written ordered: false equals an omitted one.
…e-review-edeckw # Conflicts: # CHANGELOG.md
This was referenced Oct 6, 2026
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.
Note
The following content was generated by AI.
Breaking. A dimension declares
ordered: truewhere its order is part of the model; the default isfalse.shift,sum_back,position(),piecewiseover:andsostype: 2along an unordered dimension are refused at load, naming the fix. Closes #792.snapshot: { dtype: int }withshift(p, along=snapshot, …)loadssnapshot: { dtype: int, ordered: true }What changed
DimensionBlock.ordered: bool = False. It is written only where true, so a file that never wrote it dumps unchanged. A dump that leavesorderedout (exclude_defaults,exclude_unset,exclude=) writes the dimension without it.errors.unordered, raised at five places: the expression resolver (shift,sum_back), the where resolver (shift(<predicate>),position()), andreference_errorsforpiecewiseandsostype: 2. The formulations are checked on the block, before their expansion writes theshiftandpositionthey lower to, so the refusal names the block.Namespace.unordered(name)isnot self.schema.dimensions[name].ordered. Every caller checks first that the name is a declared dimension.validation.pyreads the field directly.Program.dimensions[d].ordered.DimensionDeclarationcarries the field, so a consumer of the program sees it. Lowering builds it by keyword.orderedis a claim about the space, not the space. One rule,composition._joined, servesmergeandoverride:mergefolds it as a union: a dimension one fragment declares ordered is ordered. Every other field still has to be equal. Each fragment still loads alone.overridecompares a restated dimension or relation as the schema reads both sides, so a writtenordered: falseequals an omitted one. A patch may addordered: trueover a base without it. A patch that writesordered: falseover an ordered base is refused, because the base may already step along it. A patch that leavesorderedout over an ordered base keeps it ordered.examples/,tests/expand/, the golden model, the test fixtures, inline test specs, and the YAML blocks of the reference pages. The generated pages, the schema and the golden output are regenerated; the golden.outfiles did not change.## Ordersection. The language index gains an eleventh rule that points at it. compose states the union rule formergeand the widen-only rule for a patch, with the refusal quoted whole.Review fixes (2026-10-06)
Each fix has a test that failed on the tree before it:
Program.dimensionsdroppedorderedDimensionDeclaration.ordered, carried by loweringtest_a_program_reports_whether_a_dimension_is_ordered[ordered]ordered: falsediffered from the omitted onetest_a_patch_restates_a_dimension_as_the_schema_reads_it[false-written-out]orderedwere refusedmergefoldsorderedas a uniontest_a_dimension_one_fragment_declares_ordered_is_ordered_in_the_composition[…](both orders)ordered: trueoverridewidens…_as_the_schema_reads_it[widened-to-ordered],[ordered-left-out]test_a_patch_that_withdraws_ordered_is_refusedshift(<predicate>, along=d)withdunordered and not carried by the predicate named the order firsttest_a_where_shift_along_a_dimension_its_predicate_lacks_is_refused_for_that_firstNamespace.unorderedhad a dead branch for an undeclared nameMutation: the narrowing guard replaced by
if False:failstest_a_patch_that_withdraws_ordered_is_refusedand nothing else (1 failed, 2698 passed).Judged wrong, not changed:
generator,gandh, which they declare ordered; the default is covered byUNORDEREDintests/test_validation.py.soselifchain skips aclaimedset consistently.Update to main (2026-10-02)
origin/main(b6c2861, with #664, #834 and #835) is merged in.python -m tools.pypsa_split split examples/pypsaregenerates the fragments fromexamples/pypsa.yaml, which declaresperiodordered. The changelog line readsfeat(language)!:. #821 addsshift(…, along=period)masks to the PyPSA files; whichever of it and this PR lands second declares the dimensions it steps along as ordered.Gates
On
9595463:pixi run lint: passes.pixi run ci(lint, test, docs-build, compile-tex): passes, 2699 tests.python -m tools.schema,python -m tests.typesetting.golden,python -m tools.pypsa_split split examples/pypsaand the five page generators: no diff.Deliberately not done, and departures
docs/about/limits.mdgains no entry. It lists which words may enter the language;orderedis a rule a file obeys. Its one link to "the ten rules" now reads "the eleven rules", because the anchor moved with the new row anddocs-build --strictrefuses a stale anchor. Nothing else on that page changed.pypsa_splitstill writesordered: truein every fragment that declaressnapshotorperiod, also where the fragment does not step along it. With the union rule only the fragments that step along it need it. That is cosmetic, and filed separately.t-1, the window).intdimension may number things with no order.