From d914e52992d796f521a56adbc5157905f007a3c2 Mon Sep 17 00:00:00 2001 From: Emma Johnson Date: Mon, 4 Nov 2024 16:09:21 -0700 Subject: [PATCH] Black --- pyomo/core/plugins/transform/lp_dual.py | 8 ++--- pyomo/core/tests/unit/test_lp_dual.py | 48 ++++++++++++------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pyomo/core/plugins/transform/lp_dual.py b/pyomo/core/plugins/transform/lp_dual.py index a6c41d41053..1a2d20efd69 100644 --- a/pyomo/core/plugins/transform/lp_dual.py +++ b/pyomo/core/plugins/transform/lp_dual.py @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/pyomo/core/tests/unit/test_lp_dual.py b/pyomo/core/tests/unit/test_lp_dual.py index 34ebf5c741b..33e3e9287cd 100644 --- a/pyomo/core/tests/unit/test_lp_dual.py +++ b/pyomo/core/tests/unit/test_lp_dual.py @@ -327,11 +327,11 @@ 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]) @@ -339,9 +339,9 @@ def test_multiple_obj_error(self): 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]) @@ -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) @@ -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) @@ -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)