Skip to content

Commit

Permalink
Apply black
Browse files Browse the repository at this point in the history
  • Loading branch information
shermanjasonaf committed Aug 20, 2024
1 parent 80c2dd6 commit 96b4ede
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyomo/contrib/pyros/tests/test_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 6 additions & 11 deletions pyomo/contrib/pyros/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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())
)
)
Expand Down

0 comments on commit 96b4ede

Please sign in to comment.