diff --git a/pyomo/repn/linear_template.py b/pyomo/repn/linear_template.py index 7a00a1d5cf3..995ce370e55 100644 --- a/pyomo/repn/linear_template.py +++ b/pyomo/repn/linear_template.py @@ -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: diff --git a/pyomo/repn/plugins/parameterized_standard_form.py b/pyomo/repn/plugins/parameterized_standard_form.py index 94beb76c9f1..fb266284741 100644 --- a/pyomo/repn/plugins/parameterized_standard_form.py +++ b/pyomo/repn/plugins/parameterized_standard_form.py @@ -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 @@ -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 diff --git a/pyomo/repn/plugins/standard_form.py b/pyomo/repn/plugins/standard_form.py index ef2f8ba9332..cd73ca96695 100644 --- a/pyomo/repn/plugins/standard_form.py +++ b/pyomo/repn/plugins/standard_form.py @@ -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) @@ -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) diff --git a/pyomo/repn/tests/test_parameterized_standard_form.py b/pyomo/repn/tests/test_parameterized_standard_form.py index 6d549a14f65..56ed16342b2 100644 --- a/pyomo/repn/tests/test_parameterized_standard_form.py +++ b/pyomo/repn/tests/test_parameterized_standard_form.py @@ -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))