From a18ef57840a2d918525355a42ca46e96013a2ad1 Mon Sep 17 00:00:00 2001 From: David Ham Date: Sat, 6 Jul 2024 20:54:39 +0100 Subject: [PATCH] make solve string more robust --- firedrake/adjoint_utils/blocks/solving.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/firedrake/adjoint_utils/blocks/solving.py b/firedrake/adjoint_utils/blocks/solving.py index 694f5de7a3..9eb6a8626c 100644 --- a/firedrake/adjoint_utils/blocks/solving.py +++ b/firedrake/adjoint_utils/blocks/solving.py @@ -80,8 +80,15 @@ def _init_solver_parameters(self, args, kwargs): self.assemble_kwargs = {} def __str__(self): - return "solve({} = {})".format(ufl2unicode(self.lhs), - ufl2unicode(self.rhs)) + try: + lhs_string = ufl2unicode(self.lhs) + except AttributeError: + lhs_string = str(self.lhs) + try: + rhs_string = ufl2unicode(self.rhs) + except AttributeError: + rhs_string = str(self.rhs) + return "solve({} = {})".format(lhs_string, rhs_string) def _create_F_form(self): # Process the equation forms, replacing values with checkpoints,