Skip to content

chore(engine): the engine calls each additive part of an expression a linear, quadratic or constant term rather than a piece - #2061

Open
FBumann wants to merge 2 commits into
mainfrom
claude/determined-johnson-irmuuz
Open

FBumann wants to merge 2 commits into
mainfrom
claude/determined-johnson-irmuuz

Conversation

@FBumann

@FBumann FBumann commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Prompt: Do a pr onto specsolve main now, renaming it
And adjust other related names too.
So it's more intuitive overall

Note

The following content was generated by AI.

Piece is now Term, in _engine/terms.py. A term is linear, quadratic or constant, which retires the words "piece", "term piece", "const piece" and "constant part". The compiler's quadratic flag is now admits_quadratic. Behaviour does not change.

What was renamed
before after
_engine/pieces.py _engine/terms.py
Piece Term
kinds 'term', 'quad', 'const' 'linear', 'quadratic', 'constant'
CompiledExpression.terms, .consts, .quads .linear, .constant, .quadratic
Compiler.expression(..., quadratic=) Compiler.expression(..., admits_quadratic=)
map_pieces map_terms
refuse_a_piece_without_the_dims refuse_a_term_without_the_dims
join_mul, join_quad, join_pow times_constant, times_variable, to_the_power
_parameter_piece, _variable_piece, _solved_piece, _dual_piece, _sum_piece, _group_piece, _at_piece, _remap_piece the same names ending in _term
translate_piece, window_piece translate_term, window_term
  • The flag was renamed after a follow-up question about the names. It is a permission, not a kind of term: it says whether the position may hold a product of two variables. With its old name, a local quadratic list shadowed it. Now the locals in product, quotient and _build_constraint use the plain names linear, quadratic and constant, like the fields of CompiledExpression. Its docstring no longer says that a constraint row cannot hold a product, which was false for a quadratic constraint.
  • The flag stays because its assert checks the compiler against mathspec's is_quadratic, and declares_quadratic also decides which constraints the solver capability check sees.
  • Lists of frames that were waiting to be concatenated, which were also called pieces, are now frames (and aligned in readback).
  • The docstrings, the architecture page (node table, module table and glossary), verification.md and the test names and prose use the new words.
  • One user-visible string changed. The a constant summed beside a term is accepted by check and the linopy lane, refused by the engine #1137 refusal now says "a constant term of the expression" instead of "a constant part". The tests match on specsolve cannot build and Declare the parameter over, and both phrases are unchanged.
Verification

On dd1315d, in a uv environment that mirrors the pixi dev and docs features:

  • ruff check . and ruff format --check . pass.
  • pyrefly check reports 0 errors. On 216fa32, the linopy-reference check also reported 0 errors.
  • pytest -n auto: 5524 passed, 663 skipped, 4 xfailed, 4 failed. The 4 failures are the gurobi and xpress cases of test_a_row_with_no_terms_is_not_built_and_is_reported and test_a_solver_hands_back_a_vector_and_not_an_index. These solvers are not installed in this container, and the same 4 fail on unmodified main.
  • tests/test_docstring_links.py passes. On 216fa32, tests/test_docs_math.py passed and zensical build --strict found no issues.
  • I did not run pixi run check itself, because pixi is not installed here. I ran its parts directly.
Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_01WjaoQERHiPueVjahe7oKSG

… linear, quadratic or constant term rather than a piece

`Piece` is `Term`, in `_engine/terms.py`. Its kinds are `linear`,
`quadratic` and `constant`, and a `CompiledExpression` holds them as
`linear`, `constant` and `quadratic`. The helpers that named a piece
name a term, and the products read as what they do: `times_constant`,
`times_variable` and `to_the_power`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WjaoQERHiPueVjahe7oKSG
@read-the-docs-community

read-the-docs-community Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 specsolve | 🛠️ Build #35249363 | 📁 Comparing dd1315d against latest (5a78e3f)

  🔍 Preview build  

2 files changed
± development/architecture/index.html
± development/verification/index.html

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 104 untouched benchmarks
⏩ 307 skipped benchmarks1


Comparing claude/determined-johnson-irmuuz (dd1315d) with main (ecce0f3)2

Open in CodSpeed

Footnotes

  1. 307 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (5a78e3f) during the generation of this report, so ecce0f3 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

…ratic, so the terms keep their plain names

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WjaoQERHiPueVjahe7oKSG

This branch has not been deployed

No deployments
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.

2 participants