Skip to content

Commit

Permalink
Black
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 committed Nov 4, 2024
1 parent 7238c31 commit d914e52
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions pyomo/core/plugins/transform/lp_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_primal_constraint(self, model, dual_var):
A dual model returned from the 'core.lp_dual' transformation
dual_var: Var
A dual variable on 'model'
"""
primal_constraint = model.private_data().primal_constraint
if dual_var in primal_constraint:
Expand All @@ -201,7 +201,7 @@ def get_dual_constraint(self, model, primal_var):
A primal model passed as an argument to the 'core.lp_dual' transformation
primal_var: Var
A primal variable on 'model'
"""
dual_constraint = model.private_data().dual_constraint
if primal_var in dual_constraint:
Expand All @@ -225,7 +225,7 @@ def get_primal_var(self, model, dual_constraint):
A dual model returned from the 'core.lp_dual' transformation
dual_constraint: Constraint
A constraint on 'model'
"""
primal_var = model.private_data().primal_var
if dual_constraint in primal_var:
Expand All @@ -249,7 +249,7 @@ def get_dual_var(self, model, primal_constraint):
A primal model passed as an argument to the 'core.lp_dual' transformation
primal_constraint: Constraint
A constraint on 'model'
"""
dual_var = model.private_data().dual_var
if primal_constraint in dual_var:
Expand Down
48 changes: 24 additions & 24 deletions pyomo/core/tests/unit/test_lp_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,21 @@ def test_multiple_obj_error(self):
m.obj.deactivate()

lp_dual = TransformationFactory('core.lp_dual')

with self.assertRaisesRegex(
ValueError,
"Model 'primal' has no objective or multiple active objectives. "
"Cannot take dual with more than one objective!"
ValueError,
"Model 'primal' has no objective or multiple active objectives. "
"Cannot take dual with more than one objective!",
):
dual = lp_dual.create_using(m, parameterize_wrt=[m.outer1, m.outer])

m.obj.activate()
m.obj2 = Objective(expr=m.outer1 + m.outer[3])

with self.assertRaisesRegex(
ValueError,
"Model 'primal' has no objective or multiple active objectives. "
"Cannot take dual with more than one objective!"
ValueError,
"Model 'primal' has no objective or multiple active objectives. "
"Cannot take dual with more than one objective!",
):
dual = lp_dual.create_using(m, parameterize_wrt=[m.outer1, m.outer])

Expand All @@ -350,11 +350,11 @@ def test_primal_constraint_map_error(self):

lp_dual = TransformationFactory('core.lp_dual')
dual = lp_dual.create_using(m, parameterize_wrt=[m.outer1, m.outer])

with self.assertRaisesRegex(
ValueError,
"It does not appear that Var 'x' is a dual variable on model "
"'primal dual'"
ValueError,
"It does not appear that Var 'x' is a dual variable on model "
"'primal dual'",
):
thing = lp_dual.get_primal_constraint(dual, m.x)

Expand All @@ -363,24 +363,24 @@ def test_dual_constraint_map_error(self):

lp_dual = TransformationFactory('core.lp_dual')
dual = lp_dual.create_using(m, parameterize_wrt=[m.outer1, m.outer])

with self.assertRaisesRegex(
ValueError,
"It does not appear that Var 'outer1' is a primal variable on model "
"'primal'"
ValueError,
"It does not appear that Var 'outer1' is a primal variable on model "
"'primal'",
):
thing = lp_dual.get_dual_constraint(m, m.outer1)

def test_primal_var_map_error(self):
m = self.get_bilevel_model()

lp_dual = TransformationFactory('core.lp_dual')
dual = lp_dual.create_using(m, parameterize_wrt=[m.outer1, m.outer])

with self.assertRaisesRegex(
ValueError,
"It does not appear that Constraint 'c1' is a dual constraint "
"on model 'primal dual'"
ValueError,
"It does not appear that Constraint 'c1' is a dual constraint "
"on model 'primal dual'",
):
thing = lp_dual.get_primal_var(dual, m.c1)

Expand All @@ -391,10 +391,10 @@ def test_dual_var_map_error(self):
dual = lp_dual.create_using(m, parameterize_wrt=[m.outer1, m.outer])

m.c_new = Constraint(expr=m.x + m.y <= 35)

with self.assertRaisesRegex(
ValueError,
"It does not appear that Constraint 'c_new' is a primal constraint "
"on model 'primal'"
ValueError,
"It does not appear that Constraint 'c_new' is a primal constraint "
"on model 'primal'",
):
thing = lp_dual.get_dual_var(m, m.c_new)

0 comments on commit d914e52

Please sign in to comment.