From: Vivien Maisonneuve Date: Tue, 9 Sep 2014 09:02:20 +0000 (+0200) Subject: Make Expression.subs() always return a LinExpr instance X-Git-Tag: 1.0.2~1 X-Git-Url: https://scm.cri.mines-paristech.fr/git/linpy.git/commitdiff_plain/1044e58e639333d281d47739ba9ecef607ff14e6?hp=b77f3f44c4b15fbe2965b206bf74021377a8876a Make Expression.subs() always return a LinExpr instance --- diff --git a/linpy/linexprs.py b/linpy/linexprs.py index 3c00f22..f361218 100644 --- a/linpy/linexprs.py +++ b/linpy/linexprs.py @@ -306,7 +306,7 @@ class LinExpr: for symbol in substitutions: if not isinstance(symbol, Symbol): raise TypeError('symbols must be Symbol instances') - result = self._constant + result = Rational(self._constant) for symbol, coefficient in self._coefficients.items(): expression = substitutions.get(symbol, symbol) result += coefficient * expression