Skip to content

Commit

Permalink
Type check Action arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Dec 18, 2024
1 parent 613e63f commit 920a063
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ufl/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 920a063

Please sign in to comment.