Skip to content

Commit eabdb00

Browse files
authored
Action type check (#333)
* Fix action space check * ruff * unsafe ruff * symmetric space check * fix import conflict * Type check Action arguments
1 parent c3ce9fe commit eabdb00

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ufl/action.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ def _check_function_spaces(left, right):
179179
# `action(Coefficient(V), Cofunction(V.dual()))`.
180180
if isinstance(left, Coefficient):
181181
V_left = left.ufl_function_space()
182-
else:
182+
elif isinstance(left, BaseForm):
183183
V_left = left.arguments()[-1].ufl_function_space().dual()
184+
else:
185+
raise TypeError("Action left argument must be either Coefficient or BaseForm")
184186
if isinstance(right, Coefficient):
185187
V_right = right.ufl_function_space()
186-
else:
188+
elif isinstance(right, BaseForm):
187189
V_right = right.arguments()[0].ufl_function_space().dual()
190+
else:
191+
raise TypeError("Action right argument must be either Coefficient or BaseForm")
188192

189193
if V_left.dual() != V_right:
190194
raise TypeError("Incompatible function spaces in Action")

0 commit comments

Comments
 (0)