Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 committed Jul 11, 2024
1 parent d86e00b commit c569897
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion pyomo/repn/linear_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ def _before_named_expression(self, visitor, child):
raise NotImplementedError()



def _handle_getitem(visitor, node, comp, *args):
expr = comp[1][tuple(arg[1] for arg in args)]
if comp[0] is _CONSTANT:
Expand Down
7 changes: 4 additions & 3 deletions pyomo/repn/plugins/parameterized_standard_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def eliminate_zeros(self):
num_non_zeros += 1
jj += 1
col_index_ptr[i + 1] = num_non_zeros


class _ParameterizedLinearStandardFormCompiler_impl(_LinearStandardFormCompiler_impl):
_csc_matrix = _CSCMatrix
Expand All @@ -223,8 +223,9 @@ def _get_visitor(self, subexpression_cache, var_map, var_order, sorter):
wrt = self.config.wrt
if wrt is None:
wrt = []
return ParameterizedLinearRepnVisitor(subexpression_cache, var_map,
var_order, sorter, wrt=wrt)
return ParameterizedLinearRepnVisitor(
subexpression_cache, var_map, var_order, sorter, wrt=wrt
)

def _to_vector(self, data, N, vector_type):
# override this to not attempt conversion to float since that will fail
Expand Down
4 changes: 2 additions & 2 deletions pyomo/repn/plugins/standard_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def write(self, model):
obj_index_ptr = [0]
for obj in objectives:
if hasattr(obj, 'template_expr'):
offset, linear_index, linear_data, _, _ = (
(offset, linear_index, linear_data, _, _) = (
template_visitor.expand_expression(obj, obj.template_expr())
)
N = len(linear_index)
Expand Down Expand Up @@ -398,7 +398,7 @@ def write(self, model):
last_parent = con._component

if hasattr(con, 'template_expr'):
offset, linear_index, linear_data, lb, ub = (
(offset, linear_index, linear_data, lb, ub) = (
template_visitor.expand_expression(con, con.template_expr())
)
N = len(linear_data)
Expand Down
4 changes: 3 additions & 1 deletion pyomo/repn/tests/test_parameterized_standard_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def test_todense(self):
self.assertTrue(np.all(A.todense() == dense))
self.assertTrue(np.all(A.tocsc().todense() == dense))

A = _CSRMatrix(([5, 6, 7, 2, 1, 1.5], [0, 1, 1, 2, 3, 1], [0, 2, 4, 5, 6]), [4, 4])
A = _CSRMatrix(
([5, 6, 7, 2, 1, 1.5], [0, 1, 1, 2, 3, 1], [0, 2, 4, 5, 6]), [4, 4]
)
dense = np.array([[5, 6, 0, 0], [0, 7, 2, 0], [0, 0, 0, 1], [0, 1.5, 0, 0]])
self.assertTrue(np.all(A.todense() == dense))
self.assertTrue(np.all(A.tocsc().todense() == dense))
Expand Down

0 comments on commit c569897

Please sign in to comment.