Skip to content

Return the default from LpAffineExpression.get for missing variables - #955

Merged
pchtsp merged 1 commit into
coin-or:masterfrom
raashish1601:fix/expression-get-default
Oct 14, 2026
Merged

pchtsp merged 1 commit into
coin-or:masterfrom
raashish1601:fix/expression-get-default

Conversation

@raashish1601

Copy link
Copy Markdown
Contributor

Fixes #954.

LpAffineExpression.get relied on self[key] raising KeyError, but the Rust get_coeff returns 0.0 for a variable that isn't in the expression, so the default was never returned. get now checks membership first, which matches LpConstraint.get.

Added test_expression_get_missing_variable to test_pulp.py (it fails before the change). Ran test_pulp and test_highs locally with HiGHS, plus ruff check, ruff format --check and ty check pulp (no new warnings).

@CLAassistant

CLAassistant commented Oct 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pchtsp
pchtsp merged commit 3c7b03f into coin-or:master Oct 14, 2026
10 checks passed
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.

LpAffineExpression.get() ignores the default for variables not in the expression

3 participants