feat(language): a variable, a constraint and a cased expression declare their shape as dims, as a parameter does - #429
Conversation
Documentation build overview
44 files changed ·
|
|
@brynpickering @FabianHofmann Opinions? |
749d18e to
8c809c6
Compare
|
I like that very much, I think Note I did not take a look at the code yet and would wait until the the merge conflicts are resolved |
…re their shape as dims, as a parameter does Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QrrLMWgN7VSZ4Xxf27t9pz
8c809c6 to
bc77542
Compare
|
@FBumann @FabianHofmann the reason for
|
|
@brynpickering Do you agree that we should remove the problem of having dims and foreach interchangeably? So we merge this pr and have dims everywhere. Then we can decide about a final name in a follow up? About that final word: We have the top level concept in the yaml right now dimensions:
snapshot: { dtype: int }
generator: {}And INDEX in pandas isn't the same as dims in xarray. It's index.name = dim, index = dim.values pretty much I think dimension/dims is the best word for it. That xarray happens to use it is not a problem I think. variables:
p:
dimensions: [snapshot, generator] |
|
@FBumann yes I agree we should use the same term everywhere. I'm fine with using One caveat I'd make is that there could be a benefit to having |
…re their shape as dims, as a parameter does (#1634) > **Prompt:** Lets update lpspec to the latest mathspec release > [!NOTE] > The following content was generated by AI. Follows math-spec to `v0.0.0-alpha.88`. A variable, a constraint and a cased expression now declare their shape as `dims:`, the key a parameter already used; `foreach:` is gone from the language, so every model file in the tree is rewritten. alpha.87 is the only release in the range that changes what a file may say (energy-models/mathspec#429). alpha.86 adds the lookups to the names a mistyped `where` is answered with, and alpha.88 is documentation. The lowered `Program` this package consumes was already spelled `dims`, so no engine logic moved — the rename reaches the model files, the docstrings that quote the key, and the prose. - `pyproject.toml` and `uv.lock` to alpha.88. - `foreach:` → `dims:` across `examples/`, `differential/pypsa/rungs/`, `bench/models/`, and the inline specs under `tests/`. - Engine internals that said "the foreach dims" now say "the frame dims", and `refuse_outside_foreach` is `refuse_outside_frame`: the word was the retired key's, and what it describes is the declaration's frame. - `docs/`, `README.md` and both notebooks follow. No page needed regenerating — the three generators agree with the renamed models. No alias and no hand-written message for `foreach:`; the closed schema's own error names the valid keys. No test asserted the old spelling as behaviour, so no coverage moved. <details><summary>What was verified, and what was not</summary> Run on this branch's head, against math-spec `5656b11` (`v0.0.0-alpha.88`): ``` pytest -q -n auto 3960 passed, 251 skipped, 1 xfailed ruff check . All checks passed! ruff format --check . 318 files already formatted pyrefly check 0 errors (package, and the linopy reference scripts) pytest bench/test_harness.py 140 passed, 5 skipped (idle box, load < 3 on 4 cores) mkdocs build --strict clean python -m tools.gallery_math --check 47 pages match their models python -m tools.ladder --check clean python -m tools.constructs --check docs/examples/index.md matches the models ``` Not run: the depth-3 expression sweep, and the CodSpeed job. `bench/` carries only model files here, so the harness run is a check that the renamed models still load and solve — it takes no numbers and this PR publishes none. </details> <details><summary>The one collision the sweep created</summary> `_wide_objective_of` in `tests/test_arithmetic_laws.py` took a `foreach` argument and built a local named `dims` for the dimensions mapping, so renaming the argument made the second shadow the first and the constraint declared a mapping where a list belongs: ``` math_spec.errors.SchemaError: constraints.c.dims: Input should be a valid list ``` The local is now `dimensions`. It was the only such clash in 205 files, and the suite caught it. </details> <details><summary>Incidental lockfile churn</summary> `uv lock` also tightened six environment markers it had been carrying loose — `pycparser`, `linkify-it-py`, `ptyprocess` and memray's three. Tool output rather than an edit of mine, and left as the tool wrote it. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01C8VMbam9FtNjVAzmUYabQV --- _Generated by [Claude Code](https://claude.ai/code/session_01C8VMbam9FtNjVAzmUYabQV)_ Co-authored-by: Claude <noreply@anthropic.com>
… it is built on The merge of main brings two renames this branch predates: `foreach:` is `dims:` since energy-models/mathspec#429, and `Result.expression` is `Result.evaluate` since #1627. Both reach this example, and neither is caught by a conflict: the model file and the call site are the branch's own new content, so git carries them across untouched and the example fails at load and at read-back instead. `run.out` is unchanged — the example reproduces its recorded output exactly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C8VMbam9FtNjVAzmUYabQV
Three reference pages conflicted, each where main had rewritten the same passage this branch edited. Main's prose is kept in every case and this branch's semantics folded into it: - absence.md: main's two-paragraph shape, carrying the coverage split and this branch's "the bind is refused" for the four positions where absence has no reading. - declarations.md: main's field table and dtype section, plus the coverage row, the worked example and the four coverage paragraphs. - dimensions.md: main's three numbered rules, whose third now says a coordinate with no row is how `coverage: masked` masks rather than that it is absence — which absence.md no longer says either. The partial-lookup paragraph carries the lookup example, and the lookup field table gains the `coverage` key the schema already took. Two test fixtures declared `variables.s` with `foreach:`, which #429 renamed to `dims:` on main. Git flagged no conflict there; the four coverage tests failed until they were updated. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012k5ThJdGaqKM8NYoE2XhG5
Resolves the conflict with #429's `foreach:` to `dims:` rename across the examples, the reference pages, the tests and the golden model. Every conflicted hunk keeps this branch's spelling (`consume=`, `window=`, `columns:`) with `dims:` applied on top, except `docs/about/limits.md`, which takes #468's prose on the whole-table operator. The schema, the golden output and the four generated pages are regenerated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fhGZgaBspo7mh9Hjd3KtT
main renamed a declaration's `foreach:` to `dims:` (#429), and this branch renamed the example models' `p`, `p_max` and `p_min` to `dispatch`, `capacity` and `min_output`. Every conflict is both edits on one line, so each takes main's key with this branch's names. The five generated pages and the golden typesetter output were re-rendered rather than merged by hand. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZKoWvZmUg8XxUK3nKxMZr
Note
The following content was generated by AI.
Closes #425, the other way round from its title:
foreach:is gone and every declaration's shape isdims:, the word a parameter, the program's three declarations and the rest of the code already used. No alias: the closed schema's own error names the valid keys.What this changes
dims:on variables, constraints and cased expressions, in the model, the schema, every example, the golden model, the reference and the error messages that name the key. The program is untouched:ParameterDeclaration,VariableDeclarationandConstraintDeclarationalready saiddims. Typeset output is unchanged, so the golden.outfiles did not move.Why
One fact had two spellings on the file surface, and
foreachwas doing two jobs, naming a shape and reading as the ∀ the typesetter prints anyway (#425).What the rebase onto
eac1930resolvedFour conflicts, all where #422 removed the label-space kind of lookup out from under a passage this branch had only renamed a key in:
dimensions.md— thedtype:label-space section this branch edited is gone frommain; the one survivingforeachin the rewritten "Dimension or lookup?" paragraph took the rename.tests/fixtures.py—SMALL_MODEL'stagis a parameter onmain, not a label-space lookup; only the threevariablesentries take the rename.tests/test_lowering.py—test_a_label_space_keeps_its_dtype_and_has_no_targetis deleted onmain, so there is nothing to rename.tests/test_validation.py— one docstring line.Gates, what was regenerated, and what was left
pixiis not installed in the session that rebased this, so the gates were run tool by tool in a plain venv at the pinnedruff==0.16.1andpyrefly==1.2.0, on8c809c6, clean worktree, baseeac1930:ruff check/ruff format --checkpyrefly checkreuse lintpytest -qorigin/maingives in that venvmkdocs build --strictprettier --checkon every changed pagedocs-buildhad not been run on the pre-rebase branch; it passes here with the one intersphinx inventory (https://docs.python.org/3/objects.inv) removed frommkdocs.ymlfor the run and restored after — the proxy answers it 403, and it is the only thing that failed the gate.schema/math-spec.schema.json(the key and its title),tests/typesetting/golden/*.out(no change), the gallery pages,notation.md,operators.md,docs/index.mdandREADME.md(YAML key lines only). All were already byte-identical to what the branch carried.tests/test_dimensions.pypins the reworded constraint message, which now says "not in its dims:" and "add it to dims:".over:on a lookup and a set names one dimension, not a shape, and stays.CHANGELOG.mdkeeps its history. The docs' noun for the shape is still "the frame" where it was.Not run:
compile-tex— tectonic and typst are absent here, and the LaTeX output is byte-identical. The 6 skips are those two.pixi run ciitself was not run.Noticed, not changed:
tests/test_piecewise.pystill names a testtest_the_emitted_foreach_follows_declaration_order, the oneforeachleft in the tree outsideCHANGELOG.md. It is this branch's to rename, not the rebase's.