Unit tests for assembly with Numba and CFFI kernel throw type mismatch error

Hello,

Since a while I am trying to implement the custom kernels and custom assembler in dolfinx. I encounter a type mismatch error when calling the dolfinx.cpp.fem.Form_float64(…)
even though I was following the unit test example
python/test/unit/fem/test_custom_jit_kernels.py
Then, quite surprisingly, I discovered that when running the unit test, the same type mismatch error is thrown:

>>> test_coefficient(np.float64)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspace/acegen_fenics/tests/test_custom_jit_kernels.py", line 138, in test_coefficient
    L = Form(formtype([V._cpp_object], integrals, [vals._cpp_object], [], False, {}, None))
TypeError: __init__(): incompatible function arguments. The following argument types are supported:
    1. __init__(self, spaces: list[dolfinx.cpp.fem.FunctionSpace_float64], integrals: dict[dolfinx.cpp.fem.IntegralType, list[tuple[int, int, ndarray[dtype=int32, writable=False, shape=(*), order='C']]]], coefficients: list[dolfinx.cpp.fem.Function_float64], constants: list[dolfinx.cpp.fem.Constant_float64], need_permutation_data: bool, entity_maps: dict[dolfinx.cpp.mesh.Mesh_float64, ndarray[dtype=int32, writable=False, shape=(*), order='C']], mesh: Optional[dolfinx.cpp.mesh.Mesh_float64]) -> None
    2. __init__(self, form: int, spaces: list[dolfinx.cpp.fem.FunctionSpace_float64], coefficients: list[dolfinx.cpp.fem.Function_float64], constants: list[dolfinx.cpp.fem.Constant_float64], subdomains: dict[dolfinx.cpp.fem.IntegralType, list[tuple[int, ndarray[dtype=int32, writable=False, shape=(*), order='C']]]], entity_maps: dict[dolfinx.cpp.mesh.Mesh_float64, ndarray[dtype=int32, writable=False, shape=(*), order='C']], mesh: Optional[dolfinx.cpp.mesh.Mesh_float64]) -> None

Invoked with types: dolfinx.cpp.fem.Form_float64, list, dict, list, list, bool, dict, NoneType

Is there a bug in the unit test or I am not using it properly?

Thank you in advance for an advice/help!

Jakub

what version of dolfinx have you installed? What does python3 -c "import dolfinx; print(dolfinx.__version__)" return?

1 Like

Thank you for your super prompt reaction!
It returns version 0.8.0. So, my mistake was that I used the unit tests from ver. 0.9.0.

You could have a look at the code from the 0.8.0 release: dolfinx/python/test/unit/fem/test_custom_jit_kernels.py at v0.8.0 · FEniCS/dolfinx · GitHub

1 Like