diff --git a/pyomo/contrib/pyros/tests/test_preprocessor.py b/pyomo/contrib/pyros/tests/test_preprocessor.py index 144c3644862..582930f97d8 100644 --- a/pyomo/contrib/pyros/tests/test_preprocessor.py +++ b/pyomo/contrib/pyros/tests/test_preprocessor.py @@ -1950,7 +1950,7 @@ def test_coefficient_matching_correct_constraints_added(self): assertExpressionsEqual( self, first_stage_eq_cons["coeff_matching_eq_con_coeff_1"].expr, - m.x1 ** 3 + 0.5 + 5 * m.x1 * m.x2 * (-1) + (-1) * (m.x1 + 2) * (-1) == 0, + m.x1**3 + 0.5 + 5 * m.x1 * m.x2 * (-1) + (-1) * (m.x1 + 2) * (-1) == 0, ) assertExpressionsEqual( self, diff --git a/pyomo/contrib/pyros/util.py b/pyomo/contrib/pyros/util.py index 58595ff3e35..fb3e2e5ed7e 100644 --- a/pyomo/contrib/pyros/util.py +++ b/pyomo/contrib/pyros/util.py @@ -990,11 +990,7 @@ def preprocess(self, user_var_partitioning): def setup_quadratic_expression_visitor( - wrt, - subexpression_cache=None, - var_map=None, - var_order=None, - sorter=None, + wrt, subexpression_cache=None, var_map=None, var_order=None, sorter=None ): """Setup a parameterized quadratic expression walker.""" visitor = ParameterizedQuadraticRepnVisitor( @@ -1320,11 +1316,9 @@ def get_effective_var_partitioning(model_data): adj_var_in_con = next(iter(adj_vars_in_con)) visitor = setup_quadratic_expression_visitor(wrt=[]) ccon_expr_repn = visitor.walk_expression(expr=ccon.body - ccon.upper) - adj_var_appears_linearly = ( - adj_var_in_con - not in ComponentSet(identify_variables(ccon_expr_repn.nonlinear)) - and id(adj_var_in_con) in ComponentSet(ccon_expr_repn.linear) - ) + adj_var_appears_linearly = adj_var_in_con not in ComponentSet( + identify_variables(ccon_expr_repn.nonlinear) + ) and id(adj_var_in_con) in ComponentSet(ccon_expr_repn.linear) if adj_var_appears_linearly: adj_var_linear_coeff = ccon_expr_repn.linear[id(adj_var_in_con)] if abs(adj_var_linear_coeff) > PRETRIANGULAR_VAR_COEFF_TOL: @@ -2247,7 +2241,8 @@ def reformulate_state_var_independent_eq_cons(model_data): [expr_repn.constant] + list(expr_repn.linear.values()) + ( - [] if expr_repn.quadratic is None + [] + if expr_repn.quadratic is None else list(expr_repn.quadratic.values()) ) )