File tree 2 files changed +14
-9
lines changed
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 1
- # Release notes for cobrapy x.y.z
1
+ # Release notes for cobrapy 0.27.0
2
2
3
3
## New features
4
4
@@ -12,6 +12,8 @@ has been removed.
12
12
` loopless_solution ` now fixes the objective to its optimum as in the
13
13
originally published method and returns the objective value in the solution object.
14
14
15
+ Repair a broken test for ` fix_objective_as_constraint ` .
16
+
15
17
## Other
16
18
17
19
Backwards compatibility for pickled models has been improved.
Original file line number Diff line number Diff line change @@ -118,15 +118,18 @@ def test_absolute_expression(model: "Model") -> None:
118
118
def test_fix_objective_as_constraint (solver : str , model : "Model" ) -> None :
119
119
"""Test fixing present objective as a constraint."""
120
120
model .solver = solver
121
+ opt = model .slim_optimize ()
121
122
with model as m :
122
- su .fix_objective_as_constraint (model , 1.0 )
123
- constraint_name = m .constraints [- 1 ]
124
- assert abs (m .constraints [- 1 ].expression - m .objective .expression ) < 1e-6
125
- assert constraint_name not in m .constraints
126
- su .fix_objective_as_constraint (model )
127
- constraint_name = model .constraints [- 1 ]
128
- assert abs (model .constraints [- 1 ].expression - model .objective .expression ) < 1e-6
129
- assert constraint_name in model .constraints
123
+ su .fix_objective_as_constraint (model , 1.0 , name = "fixed" )
124
+ assert (m .constraints .fixed .expression - m .objective .expression ).simplify () == 0
125
+ assert m .constraints .fixed .lb == pytest .approx (opt )
126
+ assert "fixed" not in m .constraints
127
+ su .fix_objective_as_constraint (model , name = "fixed" )
128
+ assert (
129
+ model .constraints .fixed .expression - model .objective .expression
130
+ ).simplify () == 0
131
+ assert m .constraints .fixed .lb == pytest .approx (opt )
132
+ assert "fixed" in model .constraints
130
133
131
134
132
135
@pytest .mark .parametrize ("solver" , optlang_solvers )
You can’t perform that action at this time.
0 commit comments