Conversation
…ts groups as the file does The where vocabulary drops the parser's `Node` suffix, so `And`, `Not`, `Or` and `ParameterComparison` stand beside `Sum` and `Add` as the naming rule says; the unions are `Expression`, `Predicate`, `TypedPredicate` and `Connective`. `At` is `Pullback`, named for the coordinate map rather than the file's spelling, and `Window` is `WindowSum`, paired with `GroupSum`. A translation and a window call their axis `over`, as every other node does. The file's `expressions:` section is `Program.expressions`, and the trees a row is built from are `Program.roots`. Lookups are one group keyed by name, each with `over` and `into`, as the file declares them, rather than nested under a dimension with `target`. `Footprint.shapes` is `nodes`. Gone: the base class and its `+` and `*` sugar, the singular accessors `dimension()`, `parameter()` and `variable()`, and `DimensionDeclaration.targets`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fhGZgaBspo7mh9Hjd3KtT
|
@FabianHofmann This is a cleanup of the code that is breaking for lpspec and linopy-mathspec. I like the naming much more! Please accept. EDIT: I would defer this until we merged #437 |
|
Note The following content was generated by AI. Follow-up once #437 lands. #437 rewrites lookups as relations and redefines what
Not planned: renaming Merge order. #437 first, then this PR re-applied on top. This diff is a scripted rename over 23 files and is cheap to regenerate; rebasing #437's 84 files over these renames is manual conflict resolution in Generated by Claude Code |
Re-applies the renames on top of #437, which brought relations in. The three relation where-leaves drop the `Node` suffix with the rest. Two follow-ups #437 made possible land with it: `Walk` and `RelationDeclaration` are frozen dataclasses, the declaration no longer carries its own name because `Program.relations` keys it, and a `Walk` carries the name instead. `Sum.over`, `GroupSum.over` and `.into` keep their names, because the file kept `over=` and `into=`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fhGZgaBspo7mh9Hjd3KtT
…as the file does since #477 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fhGZgaBspo7mh9Hjd3KtT
Brings the branch up to 0b4f046. Deliberately 0b4f046 rather than main: main also carries #474, which #481 reverts — and #474 adds `walk_regions` to `program.py`, which this branch renames throughout. One file conflicted. `tests/test_lowering.py` carries both renames at once: this branch drops the `Node` suffix, and #449 renamed the gallery's `p` and `p_max` to `dispatch` and `capacity`. The merged file takes #449's values with this branch's type names, and its two API decisions hold — the mask constant is built with `Multiply(Variable(...), Parameter(...))` rather than the deleted operator sugar, and the domain is read off `program.variables` rather than the deleted `program.variable()`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017VApqcmBKLXtKTmk3ajmtK
|
Superseeded by #585 |
Note
The following content was generated by AI.
What this changes
Every public name in
math_spec.programnow follows the naming rule indocs/contributing.md, and a relation and a named expression are read from the program the way the file declares them. Nothing the language accepts, refuses or prints changes. Regenerated on top of #437 and #477.This is a break, described here because the alpha stream refuses the marker. Every rename, one row per old name:
Where nodes
AndNodeAndOrNodeOrNotNodeNotBooleanLiteralNodeBooleanLiteralParameterDefinedNodeParameterDefinedVariableDefinedNodeVariableDefinedParameterComparisonNodeParameterComparisonDimensionComparisonNodeDimensionComparisonDimensionPositionNodeDimensionPositionRelationComparisonNodeRelationComparisonRelationPairComparisonNodeRelationPairComparisonRelationDefinedNodeRelationDefinedUnions
ExpressionNodeExpressionWhereNodePredicateTypedPredicateNodeTypedPredicateConnectiveWhereNodeConnectiveExpression nodes and their fields
AtPullbackWindowWindowSumTranslate.dimensionTranslate.along, the keywordshifttakes since #477Window.dimensionWindowSum.along, the keywordsum_backtakes since #477Program and declarations
Program.named_expressionsProgram.expressions, the file's ownexpressions:sectionProgram.expressions(the objective and both sides of every constraint)Program.rootsProgram.relations, a property built from the per-dimension nestingProgram.relations, a field: aMapping[str, RelationDeclaration]keyed by name like every other groupDimensionDeclaration.relationsDimensionDeclarationcarriesdtypealoneRelationDeclaration(name, columns, key), aNamedTupleRelationDeclaration(columns, key), a frozen dataclass; the name is its key inProgram.relationsWalk(relation, consumed, produced, joined), aNamedTuplewhosenameread off the relationWalk(name, relation, consumed, produced, joined), a frozen dataclassFootprint.shapesFootprint.nodesDeleted
Expressionbase class, with__add__and__mul__Expressionis the union. BuildAdd(a, b)andMultiply(a, b)Program.dimension(name)program.dimensions[name]Program.parameter(name)program.parameters[name]Program.variable(name)program.variables[name]Kept, deliberately:
Sum.over, andover,intoandcoordinateonGroupSumandPullback. #477 settled the call keywords onover=andinto=, and the program follows the file. Also kept: the public walk helpers with no caller in this tree (fan_in,is_quadratic,parameters_of,quotients,divisor_parameters,check_message,Mask.conjuncts,Mask.names_read), since whether lpspec reads them is not visible from here.Why
The naming table says
Nodemarks the core AST and the program uses bare names, yet the program's where vocabulary carried the suffix.Atwas the file's spelling where the rule asks for the coordinate map, andWindowdid not say it sums. A translation and a window called their axisdimensionwhere every other node and the file itself name it. The file'sexpressions:arrived under a different name whileProgram.expressionsmeant something else. Relations were nested under each dimension they touch, one relation under several, and a property undid the nesting; with the group keyed by name, the declaration's ownnamefield was a second home for one fact. The singular accessors covered three of five groups, and one had no caller. The operator sugar contradicted the reading page's "you never build a node yourself".Verification
pixiis not installable in this session (the installer host is blocked), so the gates ran from auvvenv on Python 3.12 with the same pinnedruff==0.16.1andpyrefly==1.2.0.Ran on the current head:
ruff checkandruff format --checkonsrc,tests,tools: clean.pyrefly check --python-interpreter-path <venv>: 0 errors, 9 suppressed, same asmain.pytest -q -n auto: 1265 passed, 6 skipped. The 6 skips are the typst compile tests, which skip without thetypstbinding.python -m tools.schema,python -m tests.typesetting.goldenand the four page generators: no diff.mkdocs build --strict: builds, with thedocs.python.orginventory line removed locally because that host is blocked here. The config is unchanged in the commit.prettier --checkon every Markdown file: clean.Not run:
reuse lint,typos,taplo,zizmor,compile-tex, andpixi run cias one command.Coverage moved:
test_an_unknown_dimension_is_a_near_miss_rather_than_an_empty_declarationis deleted with the accessor it tested.test_a_relation_names_the_dimension_its_values_labelis replaced bytest_a_relation_is_declared_as_the_file_declares_it, which lowers a file rather than hand-building a program.test_expressions_are_the_ones_a_row_is_built_fromistest_roots_are_the_trees_a_row_is_built_from.test_a_program_seals_its_declaration_groupsnow coversrelationstoo.*and+now callMultiplyandAdd. The review claimed the sugar had no caller in tests; it had these two.WalkandRelationDeclaration, which its dataclass walk now reaches.Departed defaults: the branch name is the one this session was given rather than
<type>/<topic>in a worktree; the renames and the relation restructure ship in one PR at the follow-up's ask rather than stacked; andmainwas merged in rather than the branch rebased, because the project forbids a force-push.🤖 Generated with Claude Code
https://claude.ai/code/session_019fhGZgaBspo7mh9Hjd3KtT