Skip to content

Commit 659fb2b

Browse files
committed
Set default CONST term in Expr children
Initializes Expr children with {CONST: 0.0} by default instead of an empty dict. This ensures that expressions always have a constant term, which may help avoid issues with missing constants in further computations.
1 parent 86d60f7 commit 659fb2b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pyscipopt/expr.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Expr:
6262
"""Base class for mathematical expressions."""
6363

6464
def __init__(self, children: Optional[dict[Union[Variable, Term, Expr], float]] = None):
65-
children = children or {}
65+
children = children or {CONST: 0.0}
6666
if not all(isinstance(i, (Variable, Term, Expr)) for i in children):
6767
raise TypeError("All keys must be Variable, Term or Expr instances")
6868

0 commit comments

Comments
 (0)