Skip to content

Commit

Permalink
Fix test for objective offset (#269)
Browse files Browse the repository at this point in the history
* ensure float is returned

* update RCs

* try with explicit conversion

* fix another instance of the bug
  • Loading branch information
cdiener authored Aug 28, 2024
1 parent 629904c commit a2d6b54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Next Release
-----

1.8.3
-----
* fix the objective offset test for compatibility with Debian sid

1.8.2
-----
* fix the feasibility check in the hybrid solver
Expand Down
6 changes: 5 additions & 1 deletion src/optlang/tests/abstract_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,11 @@ def test_objective_expression_includes_constant(self):
objective = self.model.objective
self.model.objective = self.interface.Objective(objective.expression + 3)
self.model.update()
self.assertEqual((self.model.objective.expression - (objective.expression + 3.)).expand(), 0.)
self.assertEqual(
float((self.model.objective.expression -
(objective.expression + 3.)).expand().evalf()),
0.
)

def test_is_integer(self):
model = self.model
Expand Down
6 changes: 5 additions & 1 deletion src/optlang/tests/test_hybrid_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ def test_constraint_set_problem_to_None_caches_the_latest_expression_from_solver
self.assertEqual(constraint.name, "test")
self.assertEqual(constraint.lb, -100)
self.assertEqual(constraint.ub, None)
self.assertEqual((constraint.expression - (0.4 * y + 0.3 * x + 77.0 * z)).expand(), 0.0)
self.assertEqual(
float((constraint.expression -
(0.4 * y + 0.3 * x + 77.0 * z)).expand().evalf()),
0.0
)

def test_change_of_objective_is_reflected_in_low_level_solver(self):
x = Variable('x', lb=-83.3, ub=1324422.)
Expand Down

0 comments on commit a2d6b54

Please sign in to comment.