Skip to content

Commit 28656a4

Browse files
1.2.1 (#111)
- Fix: A bug where objective values could be returned as sympy number types has been fixed.
1 parent 3532302 commit 28656a4

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The following dependencies are needed.
3939

4040
- `sympy >= 1.0.0 <http://sympy.org/en/index.html>`__
4141
- `six >= 1.9.0 <https://pypi.python.org/pypi/six>`__
42-
- `swiglpk >= 1.3.0 <https://pypi.python.org/pypi/swiglpk>`__
42+
- `swiglpk >= 1.4.3 <https://pypi.python.org/pypi/swiglpk>`__
4343

4444
The following are optional dependencies that allow other solvers to be used.
4545

optlang/expression_parsing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _parse_linear_expression(expression, expanded=False, **kwargs):
8383
if not (var.is_Symbol):
8484
if var == 1:
8585
constant = var
86-
offset = coefficients[var]
86+
offset = float(coefficients[var])
8787
elif expanded:
8888
raise ValueError("Expression {} seems to be invalid".format(expression))
8989
else:
@@ -105,7 +105,7 @@ def _parse_quadratic_expression(expression, expanded=False):
105105
offset = 0
106106

107107
if expression.is_Number: # Constant expression, no coefficients
108-
return expression, linear_coefficients, quadratic_coefficients
108+
return float(expression), linear_coefficients, quadratic_coefficients
109109

110110
if expression.is_Mul:
111111
terms = (expression,)
@@ -117,7 +117,7 @@ def _parse_quadratic_expression(expression, expanded=False):
117117
try:
118118
for term in terms:
119119
if term.is_Number:
120-
offset += term
120+
offset += float(term)
121121
continue
122122
if term.is_Pow:
123123
term = 1.0 * term

0 commit comments

Comments
 (0)