Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ jobs:
. ./mypy-env/bin/activate
pip install mypy types-cffi scipy-stubs
mypy -p dolfinx
# mypy test
# mypy demo
mypy test
mypy demo

- name: Install gmsh and pyvista (and dependencies)
run: |
Expand Down
4 changes: 2 additions & 2 deletions python/demo/demo_pml.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def generate_mesh_wire(

def compute_a(nu: int, m: complex, alpha: float) -> float:
"""Compute the Mie coefficient a_nu for a cylinder."""
J_nu_alpha = jv(nu, alpha)
J_nu_malpha = jv(nu, m * alpha)
J_nu_alpha = jv(nu, alpha) # type: ignore
J_nu_malpha = jv(nu, m * alpha) # type: ignore
J_nu_alpha_p = jvp(nu, alpha, 1)
J_nu_malpha_p = jvp(nu, m * alpha, 1)

Expand Down
10 changes: 5 additions & 5 deletions python/demo/demo_pyamg.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def poisson_problem(dtype: npt.DTypeLike, solver_type: str) -> None:
solver_type: pyamg solver type, either "ruge_stuben" or
"smoothed_aggregation"
"""
real_type = np.real(dtype(0)).dtype
real_type = np.real(dtype(0)).dtype # type: ignore
mesh = create_box(
comm=MPI.COMM_WORLD,
points=[(0.0, 0.0, 0.0), (3.0, 2.0, 1.0)],
Expand All @@ -84,7 +84,7 @@ def poisson_problem(dtype: npt.DTypeLike, solver_type: str) -> None:

dofs = locate_dofs_topological(V=V, entity_dim=fdim, entities=facets)

bc = dirichletbc(value=dtype(0), dofs=dofs, V=V)
bc = dirichletbc(value=dtype(0), dofs=dofs, V=V) # type: ignore

u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
x = ufl.SpatialCoordinate(mesh)
Expand All @@ -110,14 +110,14 @@ def poisson_problem(dtype: npt.DTypeLike, solver_type: str) -> None:
print(ml)

# Solve linear systems
print(f"\nSolve Poisson equation: {dtype.__name__}")
print(f"\nSolve Poisson equation: {dtype!s}")
res: list[float] = []
tol = 1e-10 if real_type == np.float64 else 1e-6
uh.x.array[:] = ml.solve(b.array, tol=tol, residuals=res, accel="cg")
for i, q in enumerate(res):
print(f"Convergence history: iteration {i}, residual= {q}")

with io.XDMFFile(mesh.comm, f"out_pyamg/poisson_{dtype.__name__}.xdmf", "w") as file:
with io.XDMFFile(mesh.comm, f"out_pyamg/poisson_{dtype!s}.xdmf", "w") as file:
file.write_mesh(mesh)
file.write_function(uh)

Expand All @@ -126,7 +126,7 @@ def poisson_problem(dtype: npt.DTypeLike, solver_type: str) -> None:


# +
def nullspace_elasticty(Q: fem.FunctionSpace) -> list[np.ndarray]:
def nullspace_elasticty(Q: fem.FunctionSpace) -> npt.NDArray:
Comment thread
schnellerhase marked this conversation as resolved.
"""Create the elasticity (near)nulspace.

Args:
Expand Down
4 changes: 2 additions & 2 deletions python/demo/demo_scattering_boundary_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def generate_mesh_wire(
# +
def compute_a(nu: int, m: complex, alpha: float) -> float:
"""Compute the a_nu coefficient."""
J_nu_alpha = jv(nu, alpha)
J_nu_malpha = jv(nu, m * alpha)
J_nu_alpha = jv(nu, alpha) # type: ignore
J_nu_malpha = jv(nu, m * alpha) # type: ignore
J_nu_alpha_p = jvp(nu, alpha, 1)
J_nu_malpha_p = jvp(nu, m * alpha, 1)

Expand Down
5 changes: 2 additions & 3 deletions python/dolfinx/fem/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from __future__ import annotations

import numbers
from collections.abc import Callable, Iterable

import numpy as np
Expand Down Expand Up @@ -172,7 +171,7 @@ def dof_indices(self) -> tuple[npt.NDArray[np.int32], int]:


def dirichletbc(
value: Function | Constant | np.ndarray,
value: Function | Constant | np.ndarray | float | complex,
dofs: npt.NDArray[np.int32],
V: dolfinx.fem.FunctionSpace | None = None,
) -> DirichletBC:
Expand All @@ -193,7 +192,7 @@ def dirichletbc(
A representation of the boundary condition for modifying linear
systems.
"""
if isinstance(value, numbers.Number):
if isinstance(value, float | complex):
value = np.asarray(value)

try:
Expand Down
Loading