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
18 changes: 9 additions & 9 deletions python/test/unit/common/test_index_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dolfinx.mesh import GhostMode, create_unit_cube, create_unit_square


def test_sub_index_map():
def test_sub_index_map() -> None:
comm = MPI.COMM_WORLD
my_rank = comm.rank

Expand Down Expand Up @@ -69,7 +69,7 @@ def test_sub_index_map():
assert (owners[ghosts_pos_sub] == subowners).all()


def test_sub_index_map_ghost_mode_none():
def test_sub_index_map_ghost_mode_none() -> None:
n = 3
mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=GhostMode.none)
tdim = mesh.topology.dim
Expand All @@ -78,7 +78,7 @@ def test_sub_index_map_ghost_mode_none():
create_sub_index_map(map, submap_indices)


def test_index_map_ghost_lifetime():
def test_index_map_ghost_lifetime() -> None:
"""Test lifetime management of arrays."""
# Create index map with one ghost from each other process. The
# ghosts added are the ith ghost from the ith process relative to
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_index_map_ghost_lifetime():
assert np.array_equal(ghosts, map_ghosts)


def test_explicit_index_map_dest_src_order():
def test_explicit_index_map_dest_src_order() -> None:
"""Check the documented order of explicit IndexMap neighbour lists."""
comm = MPI.COMM_WORLD
if comm.size < 3:
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_explicit_index_map_dest_src_order():

# TODO: Add test for case where more than one two process shares an index
# whose owner changes in the submap
def test_create_submap_owner_change():
def test_create_submap_owner_change() -> None:
"""Test create_sub_index_map where the ownership of indices is not
preserved in the submap. The diagram illustrates the case with four
processes. Original map numbering and connectivity (G indicates a ghost
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_create_submap_owner_change():
assert np.array_equal(global_indices, np.arange(comm.rank * 2, comm.rank * 2 + 3))


def test_sub_index_map_multiple_possible_owners():
def test_sub_index_map_multiple_possible_owners() -> None:
"""Check that creating a submap doesn't crash when an index need to change owner and
there are multiple possible new owners.
"""
Expand Down Expand Up @@ -281,7 +281,7 @@ def test_sub_index_map_multiple_possible_owners():
assert sub_imap.num_ghosts == submap_num_ghosts_expected


def test_index_map_equality():
def test_index_map_equality() -> None:
"""Index maps for the same C++ object compare (and hash) equal."""
msh = create_unit_square(MPI.COMM_WORLD, 3, 3)
V = functionspace(msh, ("Lagrange", 1))
Expand Down Expand Up @@ -318,7 +318,7 @@ def _check_index_to_dest_ranks(imap):


@pytest.mark.parametrize("seed", [0, 1, 2])
def test_index_to_dest_ranks(seed):
def test_index_to_dest_ranks(seed) -> None:
"""Sharing ranks of an index map with randomly chosen ghosts."""
comm = MPI.COMM_WORLD
local_size = 10
Expand All @@ -338,7 +338,7 @@ def test_index_to_dest_ranks(seed):

@pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet])
@pytest.mark.parametrize("tdim", [2, 3])
def test_index_to_dest_ranks_mesh(ghost_mode, tdim):
def test_index_to_dest_ranks_mesh(ghost_mode, tdim) -> None:
"""Sharing ranks of the index maps of all mesh entity dimensions."""
if tdim == 2:
msh = create_unit_square(MPI.COMM_WORLD, 8, 8, ghost_mode=ghost_mode)
Expand Down
4 changes: 2 additions & 2 deletions python/test/unit/common/test_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dolfinx.mesh import create_unit_square


def test_mpi_comm_wrapper():
def test_mpi_comm_wrapper() -> None:
"""Test MPICommWrapper <-> mpi4py.MPI.Comm conversion."""
comm0 = MPI.COMM_WORLD
m = create_unit_square(comm0, 4, 4)
Expand All @@ -21,7 +21,7 @@ def test_mpi_comm_wrapper():
assert isinstance(comm1, MPI.Comm)


def test_mpi_comm_refcount():
def test_mpi_comm_refcount() -> None:
"""Test MPICommWrapper <-> mpi4py.MPI.Comm reference counting."""
comm0 = MPI.COMM_WORLD
m = create_unit_square(comm0, 4, 4)
Expand Down
2 changes: 1 addition & 1 deletion python/test/unit/common/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def collect_pkg_modules_recursive(name):


@pytest.mark.skip("Test fails when using shared linking with nanobind")
def test_all_implemented():
def test_all_implemented() -> None:
"""flake8 does not catch its warning code F822: whether the public API
offered by the members of __all__ are implemented. We therefore manually
check.
Expand Down
4 changes: 2 additions & 2 deletions python/test/unit/common/test_scatterer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@pytest.mark.parametrize("dtype", [np.int64, np.float32, np.float64, np.complex64, np.complex128])
def test_scatter_forward(dtype):
def test_scatter_forward(dtype) -> None:
"""Test forward scatter."""
comm = MPI.COMM_WORLD

Expand Down Expand Up @@ -48,7 +48,7 @@ def test_scatter_forward(dtype):


@pytest.mark.parametrize("dtype", [np.int64, np.float32, np.float64, np.complex64, np.complex128])
def test_scatter_reverse(dtype):
def test_scatter_reverse(dtype) -> None:
"""Test reverse scatter."""
comm = MPI.COMM_WORLD

Expand Down
8 changes: 4 additions & 4 deletions python/test/unit/common/test_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from dolfinx import common


def test_timer():
def test_timer() -> None:
"""Test that named Timer works."""
dt = 0.05
task = "test_named_str"
Expand All @@ -34,7 +34,7 @@ def test_timer():
assert t[1].total_seconds() > 0.045


def test_timer_flush_stop():
def test_timer_flush_stop() -> None:
"""Test stop/flush."""
t = common.Timer()
t.start()
Expand All @@ -48,7 +48,7 @@ def test_timer_flush_stop():
t.flush()


def test_context_manager_named():
def test_context_manager_named() -> None:
"""Test that named Timer works as context manager."""
task = "test_context_manager_named_str"
with common.Timer(task):
Expand All @@ -57,7 +57,7 @@ def test_context_manager_named():
assert delta[1].total_seconds() > 0.045


def test_context_manager_anonymous():
def test_context_manager_anonymous() -> None:
"""Test that anonymous Timer works with context manager."""
timer = common.Timer()
with timer:
Expand Down
10 changes: 5 additions & 5 deletions python/test/unit/fem/test_assemble_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_cell_meshtags_from_entities(mesh: Mesh, dim: int, cells: np.ndarray,

@pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet])
@pytest.mark.parametrize("meshtags_factory", [meshtags, create_cell_meshtags_from_entities])
def test_assembly_dx_domains(mode, meshtags_factory):
def test_assembly_dx_domains(mode, meshtags_factory) -> None:
mesh = create_unit_square(MPI.COMM_WORLD, 10, 10, ghost_mode=mode)
V = functionspace(mesh, ("Lagrange", 1))
u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_assembly_dx_domains(mode, meshtags_factory):


@pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet])
def test_assembly_ds_domains(mode):
def test_assembly_ds_domains(mode) -> None:
mesh = create_unit_square(MPI.COMM_WORLD, 10, 10, ghost_mode=mode)
V = functionspace(mesh, ("Lagrange", 1))
u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
Expand Down Expand Up @@ -200,7 +200,7 @@ def right(x):


@parametrize_ghost_mode
def test_assembly_dS_domains(mode):
def test_assembly_dS_domains(mode) -> None:
N = 10
mesh = create_unit_square(MPI.COMM_WORLD, N, N, ghost_mode=mode)
one = Constant(mesh, default_scalar_type(1))
Expand All @@ -210,7 +210,7 @@ def test_assembly_dS_domains(mode):


@parametrize_ghost_mode
def test_additivity(mode):
def test_additivity(mode) -> None:
mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, ghost_mode=mode)
V = functionspace(mesh, ("Lagrange", 1))

Expand Down Expand Up @@ -351,7 +351,7 @@ def create_forms(dx, ds, dS):
assert np.allclose(b.array, b_mt.array)


def test_assemble_exterior_facet():
def test_assemble_exterior_facet() -> None:
"""Check special handling of packing of integration entities for exterior facets,
which for any other co-dimensional entity is just a one-sided integral.
"""
Expand Down
6 changes: 3 additions & 3 deletions python/test/unit/fem/test_assemble_mesh_independent_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex),
],
)
def test_compiled_form(dtype):
def test_compiled_form(dtype) -> None:
"""Compile a form without an associated mesh and assemble a form over a sequence of meshes."""
real_type = dtype(0).real.dtype
c_el = basix.ufl.element("Lagrange", "triangle", 1, shape=(2,), dtype=real_type)
Expand Down Expand Up @@ -69,7 +69,7 @@ def create_and_integrate(N, compiled_form):
pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex),
],
)
def test_submesh_assembly(dtype):
def test_submesh_assembly(dtype) -> None:
"""Compile a form without an associated mesh and assemble a form over a sequence of meshes."""
real_type = dtype(0).real.dtype
c_el = basix.ufl.element("Lagrange", "triangle", 1, shape=(2,), dtype=real_type)
Expand Down Expand Up @@ -160,7 +160,7 @@ def g(x):
pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex),
],
)
def test_eliminated_data(dtype):
def test_eliminated_data(dtype) -> None:
"""Test that mesh independent compilation handles the re-ordering of coefficients and constants
when removed through differentiation.
"""
Expand Down
24 changes: 12 additions & 12 deletions python/test/unit/fem/test_assemble_submesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_submesh_cell_assembly(d, n, k, space, ghost_mode):
@pytest.mark.parametrize("k", [1, 4])
@pytest.mark.parametrize("space", ["Lagrange", "Discontinuous Lagrange"])
@pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet])
def test_submesh_facet_assembly(n, k, space, ghost_mode):
def test_submesh_facet_assembly(n, k, space, ghost_mode) -> None:
"""Test that assembling a form over the face of a unit cube gives
the same result as assembling it over a unit square.
"""
Expand Down Expand Up @@ -190,7 +190,7 @@ def M_ufl(f, g, measure):
@pytest.mark.parametrize("k", [1, 3])
@pytest.mark.parametrize("space", ["Lagrange", "Discontinuous Lagrange"])
@pytest.mark.parametrize("integral_type", ["dx", "ds", "dS"])
def test_mixed_dom_codim_0(n, k, space, integral_type):
def test_mixed_dom_codim_0(n, k, space, integral_type) -> None:
"""Test assembling forms where the trial and test functions
are defined over different meshes.
"""
Expand Down Expand Up @@ -294,7 +294,7 @@ def coeff_expr(x):

@pytest.mark.parametrize("n", [4, 6])
@pytest.mark.parametrize("k", [1, 3])
def test_mixed_dom_codim_1(n, k):
def test_mixed_dom_codim_1(n, k) -> None:
"""Test assembling forms where the trial functions, test functions
and coefficients are defined over different meshes of different topological
dimension.
Expand Down Expand Up @@ -482,7 +482,7 @@ def compute_codim1_and_manifold_dx(msh, k, integrand):
],
)
@pytest.mark.parametrize("k", [1, 3])
def test_codim_1_gradient(cell_type, expected, k):
def test_codim_1_gradient(cell_type, expected, k) -> None:
"""Grad of a codimension-1 submesh coefficient, via the parent's
facet measure and via the submesh's own cell measure.

Expand All @@ -508,7 +508,7 @@ def test_codim_1_gradient(cell_type, expected, k):
[CellType.triangle, CellType.quadrilateral, CellType.tetrahedron, CellType.hexahedron],
)
@pytest.mark.parametrize("degree", [2, 3])
def test_codim_1_gradient_higher_order_geometry(cell_type, degree):
def test_codim_1_gradient_higher_order_geometry(cell_type, degree) -> None:
"""Same test as `test_codim_1_gradient`, on curved parent geometry.

Does not have a closed form solution.
Expand All @@ -528,7 +528,7 @@ def test_codim_1_gradient_higher_order_geometry(cell_type, degree):
(CellType.hexahedron, 72.0),
],
)
def test_codim_1_spatial_coordinate(cell_type, expected):
def test_codim_1_spatial_coordinate(cell_type, expected) -> None:
"""`SpatialCoordinate` of a codimension-1 submesh under the parent's
exterior facet measure.

Expand Down Expand Up @@ -589,7 +589,7 @@ def test_codim_1_gradient_interior_facet(cell_type):
assert np.isclose(c, c_submesh)


def test_disjoint_submeshes():
def test_disjoint_submeshes() -> None:
# FIXME Simplify this test
"""Test assembly with multiple disjoint submeshes in same variational form."""
N = 10
Expand Down Expand Up @@ -878,7 +878,7 @@ def f(x):
np.testing.assert_allclose(b_submesh.array, b_ref.array, atol=tol)


def test_interior_interface():
def test_interior_interface() -> None:
"""This is a test for assembling a form over an interface between
two domains that don't overlap. The test function is defined on one
domain, and the trial function is defined on the other.
Expand Down Expand Up @@ -1065,7 +1065,7 @@ def _ridge_submesh(n, ghost_mode):

@pytest.mark.parametrize("k", [1, 2])
@pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet])
def test_mixed_dom_codim_2(k, ghost_mode):
def test_mixed_dom_codim_2(k, ghost_mode) -> None:
"""Assemble over the ridges of a mesh with data on a codim-2 submesh.

Integrating over the parent's ridges must give the same value as
Expand Down Expand Up @@ -1100,7 +1100,7 @@ def test_mixed_dom_codim_2(k, ghost_mode):


@pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet])
def test_mixed_dom_codim_2_arguments(ghost_mode):
def test_mixed_dom_codim_2_arguments(ghost_mode) -> None:
"""Arguments, not just coefficients, may live on a codim-2 submesh."""
msh, smsh, entity_map = _ridge_submesh(3, ghost_mode)

Expand All @@ -1123,7 +1123,7 @@ def test_mixed_dom_codim_2_arguments(ghost_mode):
assert np.isclose(la.norm(b), la.norm(b1))


def test_mixed_dom_entity_dim_must_match_submesh_dim():
def test_mixed_dom_entity_dim_must_match_submesh_dim() -> None:
"""The data must live on the entities being integrated over.

A ridge integral with data on a codim-1 (facet) submesh cannot be
Expand All @@ -1147,7 +1147,7 @@ def test_mixed_dom_entity_dim_must_match_submesh_dim():
fem.form(g * ufl.Measure("dr", domain=msh), entity_maps=[entity_map])


def test_mixed_dom_vertex_integral_unsupported():
def test_mixed_dom_vertex_integral_unsupported() -> None:
"""Vertex integrals with data on another mesh are not supported.

Rejected by FFCx while compiling the kernel; `Form` also refuses the
Expand Down
Loading
Loading