FEniCS / ufl

UFL - Unified Form Language
https://fenicsproject.org
GNU Lesser General Public License v3.0
97 stars 64 forks source link

Fix argument-formatter. #288

Closed jorgensd closed 3 months ago

jorgensd commented 3 months ago

Input to _afmt is a tuple of an argument and if it is complex. This cannot be unpacked with a for-loop. New test throws the following error on main:


test_check_arities.py::test_product_arity FAILED

============================================================================= FAILURES =============================================================================
________________________________________________________________________ test_product_arity ________________________________________________________________________

    def test_product_arity():
        cell = tetrahedron
        D = Mesh(FiniteElement("Lagrange", cell, 1, (3,), identity_pullback, H1))
        V = FunctionSpace(D, FiniteElement("Lagrange", cell, 2, (3,), identity_pullback, H1))
        v = TestFunction(V)
        u = TrialFunction(V)

        with pytest.raises(ArityMismatch):
            F = inner(u, u) * dx
>           compute_form_data(F, complex_mode=True)

test_check_arities.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../ufl/algorithms/compute_form_data.py:427: in compute_form_data
    check_form_arity(preprocessed_form, self.original_form.arguments(), complex_mode)
../ufl/algorithms/check_arities.py:211: in check_form_arity
    check_integrand_arity(itg.integrand(), arguments, complex_mode)
../ufl/algorithms/check_arities.py:192: in check_integrand_arity
    arg_tuples = map_expr_dag(rules, expr, compress=False)
../ufl/corealg/map_dag.py:35: in map_expr_dag
    (result,) = map_expr_dags(
../ufl/corealg/map_dag.py:103: in map_expr_dags
    r = handlers[v._ufl_typecode_](v, *[vcache[u] for u in v.ufl_operands])
../ufl/algorithms/check_arities.py:78: in product
    f"{x[0].number()}, argument is {_afmt(x)}."
../ufl/algorithms/check_arities.py:19: in _afmt
    return tuple(f"conj({arg})" if conj else str(arg) for arg, conj in atuple)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <tuple_iterator object at 0x7b0b59ffaef0>

>   return tuple(f"conj({arg})" if conj else str(arg) for arg, conj in atuple)
E   ValueError: too many values to unpack (expected 2)

../ufl/algorithms/check_arities.py:19: ValueError
jorgensd commented 3 months ago

Integration tests are failing due to the newest version of nanobind being in DOLFINx, but not in the docker images.