From 920a063eb345adcdae3bcf314fe7aa2b15ad914e Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Wed, 18 Dec 2024 08:24:07 -0600 Subject: [PATCH] Type check Action arguments --- ufl/action.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ufl/action.py b/ufl/action.py index b2f0a7ce3..ed7cf750f 100644 --- a/ufl/action.py +++ b/ufl/action.py @@ -179,12 +179,16 @@ def _check_function_spaces(left, right): # `action(Coefficient(V), Cofunction(V.dual()))`. if isinstance(left, Coefficient): V_left = left.ufl_function_space() - else: + elif isinstance(left, BaseForm): V_left = left.arguments()[-1].ufl_function_space().dual() + else: + raise TypeError("Action left argument must be either Coefficient or BaseForm") if isinstance(right, Coefficient): V_right = right.ufl_function_space() - else: + elif isinstance(right, BaseForm): V_right = right.arguments()[0].ufl_function_space().dual() + else: + raise TypeError("Action right argument must be either Coefficient or Base Form") if V_left.dual() != V_right: raise TypeError("Incompatible function spaces in Action")