Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop cffi_utils failing on KeyError #2993

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions python/dolfinx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def set_vals(A: int,

_CTYPES = {_np.int32: "int32_t", _np.int64: "int64_t",
_np.float32: "float", _np.float64: "double",
_np.complex64: "float _Complex", _np.complex128: "double _Complex"}
_np.complex64: "float _Complex", _np.complex128: "double _Complex",
_np.longlong: "long long"}
_c_int_t = _CTYPES[_PETSc.IntType] # type: ignore
_c_scalar_t = _CTYPES[_PETSc.ScalarType] # type: ignore
_ffi.cdef(f"""
Expand All @@ -194,5 +195,5 @@ def set_vals(A: int,
"""See PETSc `MatSetValuesBlockedLocal
<https://petsc.org/release/manualpages/Mat/MatSetValuesBlockedLocal>`_
documentation."""
except ImportError:
except (ImportError, KeyError):
pass
5 changes: 4 additions & 1 deletion python/test/unit/fem/test_custom_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
# Get PETSc MatSetValuesLocal interfaces
MatSetValuesLocal = petsc_numba.MatSetValuesLocal
MatSetValuesLocal_ctypes = petsc_ctypes.MatSetValuesLocal
MatSetValuesLocal_abi = petsc_cffi.MatSetValuesLocal
try:
MatSetValuesLocal_abi = petsc_cffi.MatSetValuesLocal
except AttributeError:
MatSetValuesLocal_abi = None


@numba.njit
Expand Down
Loading