Skip to content

Commit ea144b0

Browse files
authored
Fix argument-formatter. (#288)
* Check that we never get to _afmt on CI * Add failing test * Fix string formatter * Fix formatting
1 parent c73b28f commit ea144b0

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

test/test_check_arities.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,19 @@ def test_complex_arities():
6868

6969
with pytest.raises(ArityMismatch):
7070
compute_form_data(inner(conj(v), u) * dx, complex_mode=True)
71+
72+
73+
def test_product_arity():
74+
cell = tetrahedron
75+
D = Mesh(FiniteElement("Lagrange", cell, 1, (3,), identity_pullback, H1))
76+
V = FunctionSpace(D, FiniteElement("Lagrange", cell, 2, (3,), identity_pullback, H1))
77+
v = TestFunction(V)
78+
u = TrialFunction(V)
79+
80+
with pytest.raises(ArityMismatch):
81+
F = inner(u, u) * dx
82+
compute_form_data(F, complex_mode=True)
83+
84+
with pytest.raises(ArityMismatch):
85+
L = inner(v, v) * dx
86+
compute_form_data(L, complex_mode=False)

ufl/algorithms/check_arities.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Check arities."""
22

33
from itertools import chain
4+
from typing import Tuple
45

56
from ufl.classes import Argument, Zero
67
from ufl.corealg.map_dag import map_expr_dag
@@ -14,9 +15,10 @@ class ArityMismatch(BaseException):
1415
pass
1516

1617

17-
def _afmt(atuple):
18+
def _afmt(atuple: Tuple[Argument, bool]) -> str:
1819
"""Return a string representation of an arity tuple."""
19-
return tuple(f"conj({arg})" if conj else str(arg) for arg, conj in atuple)
20+
arg, conj = atuple
21+
return f"conj({arg})" if conj else str(arg)
2022

2123

2224
class ArityChecker(MultiFunction):

0 commit comments

Comments
 (0)