From de5a16a3f0a44da77f1266021f197f27052c41d4 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Thu, 9 Jul 2026 18:55:24 +0200 Subject: [PATCH 1/6] Change type signature --- python/basix/ufl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/basix/ufl.py b/python/basix/ufl.py index 0602b4b8a..e8c261b6f 100644 --- a/python/basix/ufl.py +++ b/python/basix/ufl.py @@ -200,7 +200,7 @@ def sub_elements(self) -> _typing.Sequence[_AbstractFiniteElement]: # Basix specific functions @_abstractmethod - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.ArrayLike: + def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.NDArray[np.floating]: """Tabulate the basis functions of the element. Args: From c0358e19bf3ed95e034097c2a9a3deb4142430af Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Thu, 9 Jul 2026 19:07:33 +0200 Subject: [PATCH 2/6] Fix return type --- python/basix/ufl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/basix/ufl.py b/python/basix/ufl.py index e8c261b6f..9189d9ddd 100644 --- a/python/basix/ufl.py +++ b/python/basix/ufl.py @@ -1574,7 +1574,7 @@ def element( symmetry: bool | None = None, dof_ordering: list[int] | None = None, dtype: _npt.DTypeLike | None = None, -) -> _ElementBase: +) -> _BasixElement: """Create a UFL compatible element using Basix. Args: From 08a67ccd9d0db311e3bb3714b30f99df26bfc6c8 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Thu, 9 Jul 2026 19:20:45 +0200 Subject: [PATCH 3/6] NDArraylike --- python/basix/ufl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/basix/ufl.py b/python/basix/ufl.py index 9189d9ddd..62a1c75c0 100644 --- a/python/basix/ufl.py +++ b/python/basix/ufl.py @@ -453,7 +453,7 @@ def __hash__(self) -> int: def basix_hash(self) -> int | None: return self._element.hash() - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.ArrayLike: + def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.NDArray[np.floating]: tab = self._element.tabulate(nderivs, points) # TODO: update FFCx to remove the need for transposing here return tab.transpose((0, 1, 3, 2)).reshape((tab.shape[0], tab.shape[1], -1)) # type: ignore From 834c9ad0c8918f7e24f14f72a2397bcfef5afde3 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Thu, 9 Jul 2026 19:39:25 +0200 Subject: [PATCH 4/6] ruff --- python/basix/ufl.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/basix/ufl.py b/python/basix/ufl.py index 62a1c75c0..ce32bb628 100644 --- a/python/basix/ufl.py +++ b/python/basix/ufl.py @@ -200,7 +200,9 @@ def sub_elements(self) -> _typing.Sequence[_AbstractFiniteElement]: # Basix specific functions @_abstractmethod - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.NDArray[np.floating]: + def tabulate( + self, nderivs: int, points: _npt.NDArray[np.floating] + ) -> _npt.NDArray[np.floating]: """Tabulate the basis functions of the element. Args: @@ -453,7 +455,9 @@ def __hash__(self) -> int: def basix_hash(self) -> int | None: return self._element.hash() - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.NDArray[np.floating]: + def tabulate( + self, nderivs: int, points: _npt.NDArray[np.floating] + ) -> _npt.NDArray[np.floating]: tab = self._element.tabulate(nderivs, points) # TODO: update FFCx to remove the need for transposing here return tab.transpose((0, 1, 3, 2)).reshape((tab.shape[0], tab.shape[1], -1)) # type: ignore From f7504a6c6344d9e13748c27ea48d8a61402bfcf7 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Thu, 9 Jul 2026 19:48:06 +0200 Subject: [PATCH 5/6] More --- python/basix/ufl.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/python/basix/ufl.py b/python/basix/ufl.py index ce32bb628..00bce4cb5 100644 --- a/python/basix/ufl.py +++ b/python/basix/ufl.py @@ -605,7 +605,7 @@ def __eq__(self, other) -> bool: def __hash__(self) -> int: return super().__hash__() - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.ArrayLike: + def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.NDArray[np.float64]: tables = self._element.tabulate(nderivs, points) output = [] for tbl in tables: # type: ignore @@ -773,7 +773,7 @@ def is_mixed(self) -> bool: def degree(self) -> int: return max((e.degree for e in self._sub_elements), default=-1) - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.ArrayLike: + def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.NDArray[np.float64]: tables = [] results = [e.tabulate(nderivs, points) for e in self._sub_elements] for deriv_tables in zip(*results): @@ -1044,7 +1044,7 @@ def is_quadrature(self) -> bool: def is_real(self) -> bool: return self._sub_element.is_real - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.ArrayLike: + def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.NDArray[np.float64]: assert len(self._block_shape) == 1 # TODO: block shape assert self.reference_value_size == self._block_size # TODO: remove this assumption output = [] @@ -1281,7 +1281,9 @@ def __eq__(self, other) -> bool: def __hash__(self) -> int: return super().__hash__() - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.ArrayLike: + def tabulate( + self, nderivs: int, points: _npt.NDArray[np.floating] + ) -> _npt.NDArray[np.floating]: if nderivs > 0: raise ValueError("Cannot take derivatives of Quadrature element.") @@ -1424,7 +1426,9 @@ def __hash__(self) -> int: def dtype(self) -> _npt.DTypeLike: raise NotImplementedError() - def tabulate(self, nderivs: int, points: _npt.NDArray[np.floating]) -> _npt.ArrayLike: + def tabulate( + self, nderivs: int, points: _npt.NDArray[np.floating] + ) -> _npt.NDArray[np.floating]: out = np.zeros((nderivs + 1, len(points), self.reference_value_size**2)) for v in range(self.reference_value_size): out[0, :, self.reference_value_size * v + v] = 1.0 @@ -1578,7 +1582,7 @@ def element( symmetry: bool | None = None, dof_ordering: list[int] | None = None, dtype: _npt.DTypeLike | None = None, -) -> _BasixElement: +) -> _BasixElement | _BlockedElement: """Create a UFL compatible element using Basix. Args: @@ -1919,7 +1923,7 @@ def blocked_element( sub_element: _ElementBase, shape: tuple[int, ...], symmetry: bool | None = None, -) -> _ElementBase: +) -> _BlockedElement: """Create a UFL compatible blocked element. Args: From 4b8f26ca7ed15ded6f9cf4c0075c7cf78c0e13f9 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Thu, 9 Jul 2026 20:01:07 +0200 Subject: [PATCH 6/6] dolfinx branch --- .github/workflows/fenicsx-refs.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fenicsx-refs.env b/.github/workflows/fenicsx-refs.env index b8cb43b20..97a7da3f5 100644 --- a/.github/workflows/fenicsx-refs.env +++ b/.github/workflows/fenicsx-refs.env @@ -3,4 +3,4 @@ ufl_ref=main ffcx_repository=FEniCS/ffcx ffcx_ref=main dolfinx_repository=FEniCS/dolfinx -dolfinx_ref=main +dolfinx_ref=schnellerhase/mypy-demo