Skip to content

Commit cad83ff

Browse files
committed
Fix multiplication with numeric types in Expr
Ensures that multiplication of Expr by numeric types consistently uses float conversion, preventing potential type errors when multiplying terms.
1 parent 3c88e82 commit cad83ff

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/pyscipopt/expr.pxi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ cdef class Expr:
214214
return NotImplemented
215215

216216
if isinstance(other, NUMBER_TYPES):
217-
return Expr({v: other * c for v, c in self.terms.items()})
217+
f = float(other)
218+
return Expr({v: f * c for v, c in self.terms.items()})
218219

219220
terms = {}
220221
for v1, c1 in self.terms.items():

0 commit comments

Comments
 (0)