From 366c5f235d713a06191c22606adecc6422794797 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Tue, 6 Oct 2026 15:14:14 +0200 Subject: [PATCH] Add return value annotation to tests to increase pyrefly coverage --- python/test/unit/common/test_index_map.py | 18 ++--- python/test/unit/common/test_mpi.py | 4 +- python/test/unit/common/test_public_api.py | 2 +- python/test/unit/common/test_scatterer.py | 4 +- python/test/unit/common/test_timer.py | 8 +- python/test/unit/fem/test_assemble_domains.py | 10 +-- .../test_assemble_mesh_independent_form.py | 6 +- python/test/unit/fem/test_assemble_submesh.py | 24 +++--- python/test/unit/fem/test_assembler.py | 34 ++++----- python/test/unit/fem/test_bcs.py | 14 ++-- .../test/unit/fem/test_complex_assembler.py | 4 +- python/test/unit/fem/test_constant.py | 12 +-- python/test/unit/fem/test_custom_assembler.py | 2 +- .../unit/fem/test_custom_basix_element.py | 4 +- .../test/unit/fem/test_discrete_operators.py | 12 +-- python/test/unit/fem/test_dof_coordinates.py | 4 +- python/test/unit/fem/test_dof_permuting.py | 14 ++-- python/test/unit/fem/test_dofmap.py | 16 ++-- .../test/unit/fem/test_element_integrals.py | 16 ++-- python/test/unit/fem/test_expression.py | 20 ++--- python/test/unit/fem/test_fem_pipeline.py | 48 ++++++------ python/test/unit/fem/test_forms.py | 6 +- python/test/unit/fem/test_function.py | 18 ++--- python/test/unit/fem/test_function_space.py | 22 +++--- .../test/unit/fem/test_ghost_mesh_assembly.py | 4 +- .../unit/fem/test_interpolate_geometry.py | 12 +-- python/test/unit/fem/test_interpolation.py | 52 ++++++------- python/test/unit/fem/test_manifold.py | 24 +++--- python/test/unit/fem/test_mixed_element.py | 8 +- .../unit/fem/test_petsc_discrete_operators.py | 4 +- python/test/unit/fem/test_petsc_matis.py | 6 +- .../fem/test_petsc_nonlinear_assembler.py | 6 +- python/test/unit/fem/test_problems.py | 4 +- .../test/unit/fem/test_quadrature_elements.py | 12 +-- python/test/unit/fem/test_real_space.py | 10 +-- .../test/unit/fem/test_special_functions.py | 4 +- python/test/unit/fem/test_symmetric_tensor.py | 6 +- python/test/unit/fem/test_symmetry.py | 16 ++-- python/test/unit/fem/test_vector_assemble.py | 4 +- python/test/unit/fem/test_vector_function.py | 4 +- .../unit/geometry/test_bounding_box_tree.py | 32 ++++---- python/test/unit/geometry/test_gjk.py | 18 ++--- .../unit/geometry/test_point_collision.py | 2 +- python/test/unit/graph/test_adjacencylist.py | 4 +- python/test/unit/io/test_adios2.py | 18 ++--- python/test/unit/io/test_gmsh.py | 2 +- python/test/unit/io/test_vtk.py | 32 ++++---- python/test/unit/io/test_vtkhdf.py | 18 ++--- python/test/unit/io/test_xdmf_function.py | 18 ++--- python/test/unit/io/test_xdmf_mesh.py | 10 +-- python/test/unit/io/test_xdmf_meshdata.py | 2 +- python/test/unit/la/test_matmul.py | 8 +- python/test/unit/la/test_matrix_csr.py | 26 +++---- python/test/unit/la/test_matrix_vector.py | 8 +- python/test/unit/la/test_nullspace.py | 4 +- python/test/unit/la/test_petsc_matrix.py | 2 +- python/test/unit/la/test_sparsity_pattern.py | 6 +- python/test/unit/la/test_superlu_dist.py | 6 +- python/test/unit/la/test_transpose.py | 4 +- python/test/unit/la/test_vector_scatter.py | 8 +- python/test/unit/mesh/test_cell.py | 2 +- python/test/unit/mesh/test_dual_graph.py | 2 +- python/test/unit/mesh/test_face.py | 2 +- python/test/unit/mesh/test_ghost_mesh.py | 6 +- .../test/unit/mesh/test_higher_order_mesh.py | 34 ++++----- .../unit/mesh/test_manifold_point_search.py | 2 +- python/test/unit/mesh/test_mesh.py | 76 +++++++++---------- .../test/unit/mesh/test_mesh_partitioners.py | 4 +- python/test/unit/mesh/test_meshtags.py | 4 +- python/test/unit/mesh/test_mixed_topology.py | 6 +- .../test/unit/refinement/test_refinement.py | 16 ++-- python/test/unit/refinement/test_uniform.py | 6 +- 72 files changed, 443 insertions(+), 443 deletions(-) diff --git a/python/test/unit/common/test_index_map.py b/python/test/unit/common/test_index_map.py index e26438f29ce..8c9beabfecb 100644 --- a/python/test/unit/common/test_index_map.py +++ b/python/test/unit/common/test_index_map.py @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 @@ -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. """ @@ -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)) @@ -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 @@ -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) diff --git a/python/test/unit/common/test_mpi.py b/python/test/unit/common/test_mpi.py index 80429b8b3e7..39da54cb38e 100644 --- a/python/test/unit/common/test_mpi.py +++ b/python/test/unit/common/test_mpi.py @@ -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) @@ -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) diff --git a/python/test/unit/common/test_public_api.py b/python/test/unit/common/test_public_api.py index 555072e748e..c5c897ac4d8 100644 --- a/python/test/unit/common/test_public_api.py +++ b/python/test/unit/common/test_public_api.py @@ -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. diff --git a/python/test/unit/common/test_scatterer.py b/python/test/unit/common/test_scatterer.py index 564bf755d60..277f7327050 100644 --- a/python/test/unit/common/test_scatterer.py +++ b/python/test/unit/common/test_scatterer.py @@ -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 @@ -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 diff --git a/python/test/unit/common/test_timer.py b/python/test/unit/common/test_timer.py index b86cc5ad914..b502ccbef3b 100644 --- a/python/test/unit/common/test_timer.py +++ b/python/test/unit/common/test_timer.py @@ -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" @@ -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() @@ -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): @@ -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: diff --git a/python/test/unit/fem/test_assemble_domains.py b/python/test/unit/fem/test_assemble_domains.py index 0c5bc1776ca..f1dbe9e6d32 100644 --- a/python/test/unit/fem/test_assemble_domains.py +++ b/python/test/unit/fem/test_assemble_domains.py @@ -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) @@ -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) @@ -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)) @@ -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)) @@ -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. """ diff --git a/python/test/unit/fem/test_assemble_mesh_independent_form.py b/python/test/unit/fem/test_assemble_mesh_independent_form.py index 3ad4f61c9e8..5dc2c4aa08c 100644 --- a/python/test/unit/fem/test_assemble_mesh_independent_form.py +++ b/python/test/unit/fem/test_assemble_mesh_independent_form.py @@ -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) @@ -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) @@ -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. """ diff --git a/python/test/unit/fem/test_assemble_submesh.py b/python/test/unit/fem/test_assemble_submesh.py index 1c9f4e10cf3..67970af8eb4 100644 --- a/python/test/unit/fem/test_assemble_submesh.py +++ b/python/test/unit/fem/test_assemble_submesh.py @@ -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. """ @@ -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. """ @@ -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. @@ -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. @@ -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. @@ -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. @@ -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 @@ -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. @@ -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 @@ -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) @@ -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 @@ -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 diff --git a/python/test/unit/fem/test_assembler.py b/python/test/unit/fem/test_assembler.py index fe000132e39..097f02e56fd 100644 --- a/python/test/unit/fem/test_assembler.py +++ b/python/test/unit/fem/test_assembler.py @@ -64,7 +64,7 @@ @pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet]) @dtype_parametrize -def test_assemble_functional_dx(mode, dtype): +def test_assemble_functional_dx(mode, dtype) -> None: xtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, ghost_mode=mode, dtype=xtype) M = form(1.0 * dx(domain=mesh), dtype=dtype) @@ -80,7 +80,7 @@ def test_assemble_functional_dx(mode, dtype): @pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet]) @dtype_parametrize -def test_assemble_functional_ds(mode, dtype): +def test_assemble_functional_ds(mode, dtype) -> None: xtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, ghost_mode=mode, dtype=xtype) M = form(1.0 * ds(domain=mesh), dtype=dtype) @@ -90,7 +90,7 @@ def test_assemble_functional_ds(mode, dtype): @dtype_parametrize -def test_assemble_derivatives(dtype): +def test_assemble_derivatives(dtype) -> None: """Test the original_coefficient_positions. Positions may change under differentiation (some coefficients and @@ -121,7 +121,7 @@ def test_assemble_derivatives(dtype): @pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet]) @dtype_parametrize -def test_basic_assembly(mode, dtype): +def test_basic_assembly(mode, dtype) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, ghost_mode=mode, dtype=dtype(0).real.dtype) V = functionspace(mesh, ("Lagrange", 1)) u, v = ufl.TrialFunction(V), ufl.TestFunction(V) @@ -180,7 +180,7 @@ def nest_matrix_norm(A): @pytest.mark.petsc4py -def test_vector_single_space_as_block(): +def test_vector_single_space_as_block() -> None: from dolfinx.fem.petsc import create_vector as petsc_create_vector mesh = create_unit_square(MPI.COMM_WORLD, 3, 3) @@ -195,7 +195,7 @@ class TestPETScAssemblers: """Test PETSc-based assemblers for matrices and vectors.""" @pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet]) - def test_basic_assembly_petsc_matrixcsr(self, mode): + def test_basic_assembly_petsc_matrixcsr(self, mode) -> None: """Test basic assembly of PETSc Mat and compare with MatrixCSR assembly.""" from petsc4py import PETSc @@ -774,7 +774,7 @@ def monolithic(): create_unit_cube(MPI.COMM_WORLD, 3, 7, 3, ghost_mode=GhostMode.shared_facet), ], ) - def test_assembly_solve_taylor_hood(self, mesh): + def test_assembly_solve_taylor_hood(self, mesh) -> None: """Assemble Stokes problem with Taylor-Hood elements and solve.""" from petsc4py import PETSc @@ -980,7 +980,7 @@ def monitor(ksp, its, rnorm): assert Anorm2 == pytest.approx(Anorm1, 1.0e-4) assert Pnorm2 == pytest.approx(Pnorm1, 1.0e-6) - def test_basic_interior_facet_assembly(self): + def test_basic_interior_facet_assembly(self) -> None: """Test basic assembly of interior facet terms.""" from petsc4py import PETSc @@ -1280,7 +1280,7 @@ def test_lifting_coefficients(self, kind): np.testing.assert_allclose(b.array_r, b_ref.array_r, rtol=1e-12) - def test_coefficents_non_constant(self): + def test_coefficents_non_constant(self) -> None: """Test packing coefficients with non-constant values.""" from dolfinx.fem.petsc import assemble_vector as petsc_assemble_vector @@ -1393,7 +1393,7 @@ def partitioner(comm, nparts, dual_graph, cell_weights, edge_weights, ghosting): ksp.destroy(), b.destroy(), A.destroy() @pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet]) - def test_matrix_assembly_rectangular(self, mode): + def test_matrix_assembly_rectangular(self, mode) -> None: """Test assembly of block rectangular block matrices.""" from petsc4py import PETSc @@ -1451,7 +1451,7 @@ def test_block_null_lifting(self): b = petsc_assemble_vector(L, kind=PETSc.Vec.Type.MPI) b.ghostUpdate(addv=PETSc.InsertMode.ADD, mode=PETSc.ScatterMode.REVERSE) - def test_zero_diagonal_block_no_bcs(self): + def test_zero_diagonal_block_no_bcs(self) -> None: """Test assembly of block matrix with a zero diagonal block and no BCs.""" from dolfinx.fem.petsc import assemble_matrix as petsc_assemble_matrix @@ -1469,7 +1469,7 @@ def test_zero_diagonal_block_no_bcs(self): @pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet]) @dtype_parametrize -def test_basic_assembly_constant(mode, dtype): +def test_basic_assembly_constant(mode, dtype) -> None: """Tests assembly with Constant. The following test should be sensitive to order of flattening the @@ -1504,7 +1504,7 @@ def test_basic_assembly_constant(mode, dtype): assert np.linalg.norm(b1.array * 3.0 - b2.array * 5.0) == pytest.approx(0.0, abs=1.0e-5) -def test_lambda_assembler(): +def test_lambda_assembler() -> None: """Tests assembly with a lambda function.""" mesh = create_unit_square(MPI.COMM_WORLD, 5, 5) V = functionspace(mesh, ("Lagrange", 1)) @@ -1576,7 +1576,7 @@ def test_vector_types(): @dtype_parametrize @pytest.mark.parametrize("method", ["degree", "metadata"]) -def test_mixed_quadrature(dtype, method): +def test_mixed_quadrature(dtype, method) -> None: xtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, dtype=xtype) @@ -1957,7 +1957,7 @@ def check_vertex_integral_against_sum(form, vertices, weighted=False): ), ], ) -def test_ridge_integrals_rank1_2D(cell_type, ghost_mode, dtype): +def test_ridge_integrals_rank1_2D(cell_type, ghost_mode, dtype) -> None: comm = MPI.COMM_WORLD rdtype = np.real(dtype(0)).dtype @@ -2013,7 +2013,7 @@ def test_ridge_integrals_rank1_2D(cell_type, ghost_mode, dtype): ), ], ) -def test_ridge_integrals_rank0(cell_type, ghost_mode, dtype): +def test_ridge_integrals_rank0(cell_type, ghost_mode, dtype) -> None: comm = MPI.COMM_WORLD rdtype = np.real(dtype(0)).dtype @@ -2087,7 +2087,7 @@ def marked_ridges(x): ), ], ) -def test_ridge_integrals_rank1_3D(cell_type, ghost_mode, dtype, coefficient): +def test_ridge_integrals_rank1_3D(cell_type, ghost_mode, dtype, coefficient) -> None: comm = MPI.COMM_WORLD rdtype = np.real(dtype(0)).dtype diff --git a/python/test/unit/fem/test_bcs.py b/python/test/unit/fem/test_bcs.py index 5f25294560d..6a8a009a786 100644 --- a/python/test/unit/fem/test_bcs.py +++ b/python/test/unit/fem/test_bcs.py @@ -30,7 +30,7 @@ from ufl import dx, inner -def test_locate_dofs_geometrical(): +def test_locate_dofs_geometrical() -> None: """Test that locate_dofs_geometrical, when passed two function spaces, returns the correct degrees of freedom in each space. """ @@ -160,7 +160,7 @@ def test_constant_bc_constructions(): (create_unit_cube, (MPI.COMM_WORLD, 3, 3, 3, CellType.hexahedron)), ], ) -def test_constant_bc(mesh_factory): +def test_constant_bc(mesh_factory) -> None: """Test that setting a dirichletbc with a constant yields the same result as setting it with a function. """ @@ -196,7 +196,7 @@ def test_constant_bc(mesh_factory): (create_unit_cube, (MPI.COMM_WORLD, 3, 3, 3, CellType.hexahedron)), ], ) -def test_vector_constant_bc(mesh_factory): +def test_vector_constant_bc(mesh_factory) -> None: """Test that setting a dirichletbc with a vector valued constant yields the same result as setting it with a function. """ @@ -244,7 +244,7 @@ def test_vector_constant_bc(mesh_factory): (create_unit_cube, (MPI.COMM_WORLD, 3, 3, 3, CellType.hexahedron)), ], ) -def test_sub_constant_bc(mesh_factory): +def test_sub_constant_bc(mesh_factory) -> None: """Test that setting a dirichletbc with on a component of a vector valued function yields the same result as setting it with a function. @@ -284,7 +284,7 @@ def test_sub_constant_bc(mesh_factory): (create_unit_cube, (MPI.COMM_WORLD, 3, 3, 3, CellType.hexahedron)), ], ) -def test_mixed_constant_bc(mesh_factory): +def test_mixed_constant_bc(mesh_factory) -> None: """Test that setting a dirichletbc with on a component of a mixed function yields the same result as setting it with a function. """ @@ -372,7 +372,7 @@ def test_mixed_blocked_constant(): @pytest.mark.parametrize("shape", [(), (2,), (3, 2)]) -def test_blocked_dof_ownership(shape): +def test_blocked_dof_ownership(shape) -> None: """Test that dof ownership is correctly handled for blocked function spaces.""" mesh = create_unit_square(MPI.COMM_WORLD, 4, 4) V = functionspace(mesh, ("Lagrange", 1, shape)) @@ -408,7 +408,7 @@ def test_blocked_dof_ownership(shape): assert len(unrolled_dofs_sub) == len(boundary_dofs_V) -def test_bc_index_out_of_range(): +def test_bc_index_out_of_range() -> None: mesh = create_unit_square(MPI.COMM_WORLD, 4, 4) mesh.topology.create_connectivity(mesh.topology.dim - 1, mesh.topology.dim) facet_map = mesh.topology.index_map(mesh.topology.dim - 1) diff --git a/python/test/unit/fem/test_complex_assembler.py b/python/test/unit/fem/test_complex_assembler.py index 85d2b2ca491..b858a560ad9 100644 --- a/python/test/unit/fem/test_complex_assembler.py +++ b/python/test/unit/fem/test_complex_assembler.py @@ -24,7 +24,7 @@ @pytest.mark.parametrize("complex_dtype", [np.complex64, np.complex128]) -def test_complex_assembly(complex_dtype): +def test_complex_assembly(complex_dtype) -> None: """Test assembly of complex matrices and vectors.""" real_dtype = np.real(complex_dtype(1.0)).dtype mesh = create_unit_square(MPI.COMM_WORLD, 10, 10, dtype=real_dtype) @@ -75,7 +75,7 @@ def test_complex_assembly(complex_dtype): @pytest.mark.parametrize("complex_dtype", [np.complex64, np.complex128]) -def test_complex_assembly_solve(complex_dtype, cg_solver): +def test_complex_assembly_solve(complex_dtype, cg_solver) -> None: """Solve a positive definite helmholtz problem and verify solution with the method of manufactured solutions. """ diff --git a/python/test/unit/fem/test_constant.py b/python/test/unit/fem/test_constant.py index 4f328ca7551..7106d142ec1 100644 --- a/python/test/unit/fem/test_constant.py +++ b/python/test/unit/fem/test_constant.py @@ -25,14 +25,14 @@ def test_scalar_constant() -> None: assert c.value == 3.0 # /NOSONAR -def test_reshape(): +def test_reshape() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) c = Constant(mesh, 1.0) with pytest.raises(ValueError): c.value.resize(100) -def test_wrong_dim(): +def test_wrong_dim() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) c = Constant(mesh, [1.0, 2.0]) assert c.value.shape == (2,) @@ -40,7 +40,7 @@ def test_wrong_dim(): c.value = [1.0, 2.0, 3.0] -def test_vector_constant(): +def test_vector_constant() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) c0 = Constant(mesh, [1.0, 2.0]) c1 = Constant(mesh, np.array([1.0, 2.0])) @@ -51,7 +51,7 @@ def test_vector_constant(): assert c0.value[0] == c0.value[1] -def test_tensor_constant(): +def test_tensor_constant() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) data = [[1.0, 2.0, 1.0], [1.0, 2.0, 1.0], [1.0, 2.0, 1.0]] c0 = Constant(mesh, data) @@ -61,14 +61,14 @@ def test_tensor_constant(): assert c0.value.all() == (2.0 * np.asarray(data)).all() -def test_float_method(): +def test_float_method() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) a = 1.0 c0 = Constant(mesh, a) assert a == float(c0) # /NOSONAR -def test_complex_method(): +def test_complex_method() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) a = 1.0 + 1.0j c0 = Constant(mesh, a) diff --git a/python/test/unit/fem/test_custom_assembler.py b/python/test/unit/fem/test_custom_assembler.py index 49f3d6078a8..2193e546e52 100644 --- a/python/test/unit/fem/test_custom_assembler.py +++ b/python/test/unit/fem/test_custom_assembler.py @@ -137,7 +137,7 @@ def assemble_vector_ufc(b, kernel, mesh, dofmap, num_cells, dtype): ), ], ) -def test_custom_mesh_loop_rank1(dtype): +def test_custom_mesh_loop_rank1(dtype) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 64, 64, dtype=dtype(0).real.dtype) V = functionspace(mesh, ("Lagrange", 1)) diff --git a/python/test/unit/fem/test_custom_basix_element.py b/python/test/unit/fem/test_custom_basix_element.py index 70a07a161c0..a34aa4420b5 100644 --- a/python/test/unit/fem/test_custom_basix_element.py +++ b/python/test/unit/fem/test_custom_basix_element.py @@ -84,7 +84,7 @@ def run_scalar_test(V, degree, dtype, cg_solver, rtol=None): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("degree", range(1, 6)) -def test_basix_element_wrapper(degree, dtype, cg_solver): +def test_basix_element_wrapper(degree, dtype, cg_solver) -> None: ufl_element = basix.ufl.element( basix.ElementFamily.P, basix.CellType.triangle, @@ -129,7 +129,7 @@ def test_custom_element_triangle_degree1(dtype, cg_solver): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_custom_element_triangle_degree4(dtype, cg_solver): +def test_custom_element_triangle_degree4(dtype, cg_solver) -> None: wcoeffs = np.eye(15) x = [ [np.array([[0.0, 0.0]]), np.array([[1.0, 0.0]]), np.array([[0.0, 1.0]])], diff --git a/python/test/unit/fem/test_discrete_operators.py b/python/test/unit/fem/test_discrete_operators.py index 9e127d39536..c1f109b4f45 100644 --- a/python/test/unit/fem/test_discrete_operators.py +++ b/python/test/unit/fem/test_discrete_operators.py @@ -32,7 +32,7 @@ ), ], ) -def test_gradient(mesh): +def test_gradient(mesh) -> None: """Test discrete gradient computation for lowest order elements.""" V = functionspace(mesh, ("Lagrange", 1)) W = functionspace(mesh, ("Nedelec 1st kind H(curl)", 1)) @@ -49,7 +49,7 @@ def test_gradient(mesh): @pytest.mark.parametrize("cell", [CellType.triangle, CellType.quadrilateral]) -def test_discrete_curl_gdim_raises(cell): +def test_discrete_curl_gdim_raises(cell) -> None: """Test that discrete curl function raises for gdim != 3.""" msh = create_unit_square(MPI.COMM_WORLD, 3, 3, cell_type=cell, dtype=np.float64) E0 = element("N1curl", msh.basix_cell(), 2, dtype=np.float64) @@ -80,7 +80,7 @@ def test_discrete_curl_gdim_raises(cell): ), ], ) -def test_discrete_curl_map_raises(elements): +def test_discrete_curl_map_raises(elements) -> None: """Test that discrete curl function raises for incorrect spaces.""" msh = create_unit_cube( MPI.COMM_WORLD, 3, 3, 3, cell_type=CellType.tetrahedron, dtype=np.float64 @@ -285,7 +285,7 @@ def test_discrete_curl(element_data, p, dtype): ), ], ) -def test_gradient_interpolation(cell_type, p, q): +def test_gradient_interpolation(cell_type, p, q) -> None: """Test discrete gradient computation with verification using Expression.""" mesh, family0, family1 = cell_type dtype = mesh.geometry.x.dtype @@ -327,7 +327,7 @@ def test_gradient_interpolation(cell_type, p, q): "cell_type", [CellType.quadrilateral, CellType.triangle, CellType.tetrahedron, CellType.hexahedron], ) -def test_interpolation_matrix(dtype, cell_type, p, q, from_lagrange): +def test_interpolation_matrix(dtype, cell_type, p, q, from_lagrange) -> None: """Test that discrete interpolation matrix yields the same result as interpolation.""" from dolfinx.fem import interpolation_matrix @@ -398,7 +398,7 @@ def f(x): "cell_type", [CellType.triangle, CellType.quadrilateral, CellType.tetrahedron, CellType.hexahedron], ) -def test_discrete_interpolation(cell_type, dtype): +def test_discrete_interpolation(cell_type, dtype) -> None: tdim = cell_dim(cell_type) if tdim == 2: mesh = dolfinx.mesh.create_unit_square( diff --git a/python/test/unit/fem/test_dof_coordinates.py b/python/test/unit/fem/test_dof_coordinates.py index 2d0b124c6ca..1fc88a921e4 100644 --- a/python/test/unit/fem/test_dof_coordinates.py +++ b/python/test/unit/fem/test_dof_coordinates.py @@ -15,7 +15,7 @@ @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("degree", range(1, 5)) -def test_dof_coords_2d(degree, dtype): +def test_dof_coords_2d(degree, dtype) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 10, 10, dtype=dtype) V = functionspace(mesh, ("Lagrange", degree)) u = Function(V, dtype=dtype) @@ -27,7 +27,7 @@ def test_dof_coords_2d(degree, dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("degree", range(1, 5)) -def test_dof_coords_3d(degree, dtype): +def test_dof_coords_3d(degree, dtype) -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 10, 10, 10, dtype=dtype) V = functionspace(mesh, ("Lagrange", degree)) u = Function(V, dtype=dtype) diff --git a/python/test/unit/fem/test_dof_permuting.py b/python/test/unit/fem/test_dof_permuting.py index 30f093323da..c741ee07603 100644 --- a/python/test/unit/fem/test_dof_permuting.py +++ b/python/test/unit/fem/test_dof_permuting.py @@ -149,7 +149,7 @@ def randomly_ordered_mesh(cell_type): @pytest.mark.parametrize("space_type", [("P", 1), ("P", 2), ("P", 3), ("P", 4)]) @pytest.mark.parametrize("cell_type", ["triangle", "tetrahedron", "quadrilateral", "hexahedron"]) -def test_dof_positions(cell_type, space_type): +def test_dof_positions(cell_type, space_type) -> None: """Checks that dofs on shared triangle edges match up.""" mesh = randomly_ordered_mesh(cell_type) @@ -292,7 +292,7 @@ def random_evaluation_mesh(cell_type, dtype=default_real_type): + [("hexahedron", s) for s in ["Q", "S", "NCE", "NCF", "AAE", "AAF"]], ) @pytest.mark.parametrize("space_order", range(1, 4)) -def test_evaluation(cell_type, space_type, space_order): +def test_evaluation(cell_type, space_type, space_order) -> None: if cell_type == "hexahedron" and space_order > 3: pytest.skip("Skipping expensive test on hexahedron") @@ -369,7 +369,7 @@ def test_evaluation(cell_type, space_type, space_order): ), ], ) -def test_integral(cell_type, space_type, space_order, dtype): +def test_integral(cell_type, space_type, space_order, dtype) -> None: if cell_type == "hexahedron" and space_order >= 3: pytest.skip("Skipping expensive test on hexahedron") @@ -436,7 +436,7 @@ def tangent2(x): ], ) @pytest.mark.parametrize("space_order", range(3, 5)) -def test_permutation_wrappers(space_order, data_types): +def test_permutation_wrappers(space_order, data_types) -> None: s_type, d_type = data_types domain = create_unit_cube(MPI.COMM_WORLD, 5, 3, 4, dtype=s_type) V = functionspace(domain, ("N1curl", space_order)) @@ -456,7 +456,7 @@ def test_permutation_wrappers(space_order, data_types): @pytest.mark.parametrize("dtype", [np.float64, np.complex128]) @pytest.mark.parametrize("ttype", [0, 1, 2, 3]) # doftransform: standard/transpose/inverse/... -def test_mixed_element_dof_transformation_right(ttype, dtype): +def test_mixed_element_dof_transformation_right(ttype, dtype) -> None: """Check a mixed element's right (post-)transformation is row-consistent. Each row of (block_size, ndofs) data must be transformed over its own @@ -516,7 +516,7 @@ def test_mixed_element_dof_transformation_right(ttype, dtype): @pytest.mark.parametrize("dtype", [np.float64, np.complex128]) @pytest.mark.parametrize("ttype", [0, 1, 2, 3]) -def test_mixed_element_dof_transformation_right_zero_offset(ttype, dtype): +def test_mixed_element_dof_transformation_right_zero_offset(ttype, dtype) -> None: """As above, but with the transforming sub-element first, at offset 0. This is the case that the pre-fix sub-span slicing got right, so it @@ -558,7 +558,7 @@ def test_mixed_element_dof_transformation_right_zero_offset(ttype, dtype): @pytest.mark.parametrize("dtype", [np.float64, np.complex128]) @pytest.mark.parametrize("ttype", [0, 1, 2, 3]) -def test_non_mixed_element_dof_transformation_right(ttype, dtype): +def test_non_mixed_element_dof_transformation_right(ttype, dtype) -> None: """As above, but for the leaf (non-mixed) code path, for contrast.""" ufl_e = element( basix.ElementFamily.N1E, diff --git a/python/test/unit/fem/test_dofmap.py b/python/test/unit/fem/test_dofmap.py index a13c6dc1c00..af587cced43 100644 --- a/python/test/unit/fem/test_dofmap.py +++ b/python/test/unit/fem/test_dofmap.py @@ -87,7 +87,7 @@ def test_tabulate_dofs(mesh_factory): assert np.array_equal(combined_dofs, dofs3) -def test_entity_dofs(mesh): +def test_entity_dofs(mesh) -> None: """Test that num entity dofs is correctly wrapped to dolfinx::DofMap.""" gdim = mesh.geometry.dim @@ -129,7 +129,7 @@ def test_entity_dofs(mesh): assert all(d == cd for d, cd in zip(dofs, cdofs, strict=True)) -def test_dofmaps_is_immutable(mesh): +def test_dofmaps_is_immutable(mesh) -> None: """Test that the returned dofmaps cannot be used to modify the space.""" V = functionspace(mesh, ("Lagrange", 1)) dofmaps = V.dofmaps @@ -350,7 +350,7 @@ def test_readonly_view_local_to_global_unwoned(mesh): ), ], ) -def test_higher_order_coordinate_map(points, celltype, order): +def test_higher_order_coordinate_map(points, celltype, order) -> None: """Computes physical coordinates of a cell, based on the coordinate map.""" cells = np.array([range(len(points))]) domain = ufl.Mesh( @@ -381,7 +381,7 @@ def test_higher_order_coordinate_map(points, celltype, order): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2]) -def test_higher_order_tetra_coordinate_map(order): +def test_higher_order_tetra_coordinate_map(order) -> None: """Compute physical coordinates of a cell from the coordinate map.""" celltype = CellType.tetrahedron points = np.array( @@ -449,7 +449,7 @@ def test_higher_order_tetra_coordinate_map(order): @pytest.mark.skip_in_parallel -def test_transpose_dofmap(): +def test_transpose_dofmap() -> None: dofmap = np.array([[0, 2, 1], [3, 2, 1], [4, 3, 1]], dtype=np.int32) transpose = transpose_dofmap(dofmap, 3) assert np.array_equal(transpose.array, [0, 2, 5, 8, 1, 4, 3, 7, 6]) @@ -480,7 +480,7 @@ def self_partitioner(comm: MPI.Intracomm, n, dual_graph, cell_weights, edge_weig @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("is_affine", [True, False]) -def test_push_forward_pull_back(gdim: int, is_affine: bool): +def test_push_forward_pull_back(gdim: int, is_affine: bool) -> None: if gdim == 2: ct = CellType.triangle if is_affine else CellType.quadrilateral mesh = create_unit_square(MPI.COMM_WORLD, 4, 4, ct) @@ -556,7 +556,7 @@ def test_discontinuous_coordinate_element(dtype, degree): @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("is_affine", [True, False]) -def test_undersized_working_array(gdim: int, is_affine: bool): +def test_undersized_working_array(gdim: int, is_affine: bool) -> None: """Test that an error is raised when the working memory is too small.""" if gdim == 2: ct = CellType.triangle if is_affine else CellType.quadrilateral @@ -582,7 +582,7 @@ def test_undersized_working_array(gdim: int, is_affine: bool): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_discontinuous_coordinate_element_assembly(dtype): +def test_discontinuous_coordinate_element_assembly(dtype) -> None: """Test that a discontinuous coordinate element can be used in assembly.""" mesh = create_unit_square(MPI.COMM_WORLD, 4, 4, dtype=dtype) diff --git a/python/test/unit/fem/test_element_integrals.py b/python/test/unit/fem/test_element_integrals.py index 7399332ea60..a83ea223e1f 100644 --- a/python/test/unit/fem/test_element_integrals.py +++ b/python/test/unit/fem/test_element_integrals.py @@ -199,7 +199,7 @@ def two_unit_cells(cell_type, dtype, agree=False, random_order=True, return_orde @pytest.mark.skip_in_parallel @parametrize_cell_types @parametrize_dtypes -def test_facet_integral(cell_type, dtype): +def test_facet_integral(cell_type, dtype) -> None: """Test that the integral of a function over a facet is correct.""" xtype = np.real(dtype(0)).dtype for count in range(5): @@ -249,7 +249,7 @@ def test_facet_integral(cell_type, dtype): @pytest.mark.skip_in_parallel @parametrize_cell_types @parametrize_dtypes -def test_facet_normals(cell_type, dtype): +def test_facet_normals(cell_type, dtype) -> None: """Test that FacetNormal is outward facing.""" xtype = np.real(dtype(0)).dtype for count in range(5): @@ -325,7 +325,7 @@ def test_facet_normals(cell_type, dtype): @pytest.mark.parametrize("space_type", ["Lagrange", "DG"]) @parametrize_cell_types @parametrize_dtypes -def test_plus_minus(cell_type, space_type, dtype): +def test_plus_minus(cell_type, space_type, dtype) -> None: """Test that ('+') and ('-') give the same value for continuous functions.""" xtype = np.real(dtype(0)).dtype results = [] @@ -347,7 +347,7 @@ def test_plus_minus(cell_type, space_type, dtype): @pytest.mark.parametrize("pm", ["+", "-"]) @parametrize_cell_types @parametrize_dtypes -def test_plus_minus_simple_vector(cell_type, pm, dtype): +def test_plus_minus_simple_vector(cell_type, pm, dtype) -> None: """Test that ('+') and ('-') match up with the correct DOFs for DG functions.""" xtype = np.real(dtype(0)).dtype results = [] @@ -400,7 +400,7 @@ def test_plus_minus_simple_vector(cell_type, pm, dtype): @pytest.mark.parametrize("pm2", ["+", "-"]) @parametrize_cell_types @parametrize_dtypes -def test_plus_minus_vector(cell_type, pm1, pm2, dtype): +def test_plus_minus_vector(cell_type, pm1, pm2, dtype) -> None: """Test that ('+') and ('-') match up with the correct DOFs for DG functions.""" xtype = np.real(dtype(0)).dtype results = [] @@ -455,7 +455,7 @@ def test_plus_minus_vector(cell_type, pm1, pm2, dtype): @pytest.mark.parametrize("pm2", ["+", "-"]) @parametrize_cell_types @parametrize_dtypes -def test_plus_minus_matrix(cell_type, pm1, pm2, dtype): +def test_plus_minus_matrix(cell_type, pm1, pm2, dtype) -> None: """Test that ('+') and ('-') match up with the correct DOFs for DG functions.""" xtype = np.real(dtype(0)).dtype results = [] @@ -588,7 +588,7 @@ def create_quad_mesh(offset, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("k", [0, 1, 2]) @parametrize_dtypes -def test_div_general_quads_mat(k, dtype): +def test_div_general_quads_mat(k, dtype) -> None: """Tests that assembling inner(u, div(w)) * dx, where u is from a "DQ" space and w is from an "RTCF" space, gives the same matrix for square and trapezoidal elements. This should be the case due to the @@ -618,7 +618,7 @@ def assemble_div_matrix(k, offset): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("k", [0, 1, 2]) @parametrize_dtypes -def test_div_general_quads_vec(k, dtype): +def test_div_general_quads_vec(k, dtype) -> None: """Tests that assembling inner(1, div(w)) * dx, where w is from an "RTCF" space, gives the same matrix for square and trapezoidal elements. This should be the case due to the properties of the Piola diff --git a/python/test/unit/fem/test_expression.py b/python/test/unit/fem/test_expression.py index 6485bb79793..192262432e2 100644 --- a/python/test/unit/fem/test_expression.py +++ b/python/test/unit/fem/test_expression.py @@ -35,7 +35,7 @@ pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_rank0(dtype): +def test_rank0(dtype) -> None: """Test evaluation of UFL expression. This test evaluates gradient of P2 function at interpolation points @@ -88,7 +88,7 @@ def scatter(vec, array_evaluated, dofmap): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_rank1_hdiv(dtype): +def test_rank1_hdiv(dtype) -> None: """Test rank-1 Expression, i.e. Expression containing Argument (TrialFunction). @@ -156,7 +156,7 @@ def scatter(A, array_evaluated, dofmap0, dofmap1): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_simple_evaluation(dtype): +def test_simple_evaluation(dtype) -> None: """Test evaluation of UFL Expression. This test evaluates a UFL Expression on cells of the mesh and @@ -247,7 +247,7 @@ def exact_grad_f(x): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_assembly_into_quadrature_function(dtype): +def test_assembly_into_quadrature_function(dtype) -> None: """Test assembly into a Quadrature function. This test evaluates a UFL Expression into a Quadrature function @@ -390,7 +390,7 @@ def test_expression_eval_cells_subset(dtype): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_expression_comm(dtype): +def test_expression_comm(dtype) -> None: xtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 4, 4, dtype=xtype) v = Constant(mesh, dtype(1)) @@ -427,7 +427,7 @@ def compute_exterior_facet_entities(mesh, facets): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_facet_expression(dtype): +def test_facet_expression(dtype) -> None: xtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 4, 3, dtype=xtype) n = ufl.FacetNormal(mesh) @@ -496,7 +496,7 @@ def test_facet_expression(dtype): assert np.allclose(values, exact_expr, atol=atol) -def test_rank1_blocked(): +def test_rank1_blocked() -> None: """Check that a test function with tensor shape is unrolled as (num_cells, num_points, num_dofs, bs) when evaluated as an expression. @@ -544,7 +544,7 @@ def test_rank1_blocked(): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_submesh_codim_zero(dtype, qdegree): +def test_submesh_codim_zero(dtype, qdegree) -> None: xtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 4, 3, dtype=xtype) @@ -596,7 +596,7 @@ def mark_left_cells(x): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_submesh_codim_one(dtype, qdegree): +def test_submesh_codim_one(dtype, qdegree) -> None: xtype = dtype(0).real.dtype L = 2.1 mesh = create_rectangle( @@ -659,7 +659,7 @@ def combined_expr(u, u_sub, n_h): np.float64, ], ) -def test_skewed_quadrature(dtype): +def test_skewed_quadrature(dtype) -> None: xtype = dtype(0).real.dtype L = 2.1 mesh = create_rectangle( diff --git a/python/test/unit/fem/test_fem_pipeline.py b/python/test/unit/fem/test_fem_pipeline.py index 2424eae4e1f..a5a7dacedc8 100644 --- a/python/test/unit/fem/test_fem_pipeline.py +++ b/python/test/unit/fem/test_fem_pipeline.py @@ -224,7 +224,7 @@ def run_dg_test(mesh, V, degree, cg_solver): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_curl_curl_eigenvalue(family, order, dtype): +def test_curl_curl_eigenvalue(family, order, dtype) -> None: """curl-curl eigenvalue problem. Solved using H(curl)-conforming finite element method. @@ -289,7 +289,7 @@ def test_curl_curl_eigenvalue(family, order, dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("family", ["HHJ", "Regge"]) -def test_biharmonic(family, dtype): +def test_biharmonic(family, dtype) -> None: """Manufactured biharmonic problem. Solved using rotated Regge or the Hellan-Herrmann-Johnson (HHJ) @@ -483,7 +483,7 @@ def get_mesh(cell_type, datadir): @parametrize_cell_types_simplex @pytest.mark.parametrize("family", ["Lagrange"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_P_simplex(family, degree, cell_type, datadir, cg_solver): +def test_P_simplex(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.tetrahedron and degree == 4: pytest.skip("Skip expensive test on tetrahedron") mesh = get_mesh(cell_type, datadir) @@ -495,7 +495,7 @@ def test_P_simplex(family, degree, cell_type, datadir, cg_solver): @pytest.mark.parametrize("family", ["Lagrange"]) @pytest.mark.parametrize("degree", [2, 3, 4]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_P_simplex_built_in(family, degree, dtype, cell_type, datadir, cg_solver): +def test_P_simplex_built_in(family, degree, dtype, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.tetrahedron: mesh = create_unit_cube(MPI.COMM_WORLD, 5, 5, 5, dtype=dtype) elif cell_type == CellType.triangle: @@ -508,7 +508,7 @@ def test_P_simplex_built_in(family, degree, dtype, cell_type, datadir, cg_solver @parametrize_cell_types_simplex @pytest.mark.parametrize("family", ["Lagrange"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_vector_P_simplex(family, degree, cell_type, datadir, cg_solver): +def test_vector_P_simplex(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.tetrahedron and degree == 4: pytest.skip("Skip expensive test on tetrahedron") mesh = get_mesh(cell_type, datadir) @@ -521,7 +521,7 @@ def test_vector_P_simplex(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_simplex @pytest.mark.parametrize("family", ["DG"]) @pytest.mark.parametrize("degree", [2, 3]) -def test_dP_simplex(family, degree, cell_type, datadir, cg_solver): +def test_dP_simplex(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_dg_test(mesh, V, degree, cg_solver) @@ -531,7 +531,7 @@ def test_dP_simplex(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_simplex @pytest.mark.parametrize("family", ["RT", "N1curl"]) @pytest.mark.parametrize("degree", [1, 2, 3, 4]) -def test_RT_N1curl_simplex(family, degree, cell_type, datadir, cg_solver): +def test_RT_N1curl_simplex(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.tetrahedron and degree == 4: pytest.skip("Skip expensive test on tetrahedron") mesh = get_mesh(cell_type, datadir) @@ -543,7 +543,7 @@ def test_RT_N1curl_simplex(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_simplex @pytest.mark.parametrize("family", ["Discontinuous Raviart-Thomas"]) @pytest.mark.parametrize("degree", [1, 2, 3, 4]) -def test_discontinuous_RT(family, degree, cell_type, datadir, cg_solver): +def test_discontinuous_RT(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.tetrahedron and degree == 4: pytest.skip("Skip expensive test on tetrahedron") mesh = get_mesh(cell_type, datadir) @@ -555,7 +555,7 @@ def test_discontinuous_RT(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_simplex @pytest.mark.parametrize("family", ["BDM", "N2curl"]) @pytest.mark.parametrize("degree", [1, 2]) -def test_BDM_N2curl_simplex(family, degree, cell_type, datadir, cg_solver): +def test_BDM_N2curl_simplex(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_vector_test(mesh, V, degree, cg_solver) @@ -567,7 +567,7 @@ def test_BDM_N2curl_simplex(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_simplex @pytest.mark.parametrize("family", ["BDM", "N2curl"]) @pytest.mark.parametrize("degree", [3]) -def test_BDM_N2curl_simplex_highest_order(family, degree, cell_type, datadir, cg_solver): +def test_BDM_N2curl_simplex_highest_order(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_vector_test(mesh, V, degree, cg_solver, maxit=900, rtol=1e-5) @@ -579,7 +579,7 @@ def test_BDM_N2curl_simplex_highest_order(family, degree, cell_type, datadir, cg @parametrize_cell_types_tp @pytest.mark.parametrize("family", ["Q"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_P_tp(family, degree, cell_type, datadir, cg_solver): +def test_P_tp(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_scalar_test(mesh, V, degree, cg_solver) @@ -589,7 +589,7 @@ def test_P_tp(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_tp @pytest.mark.parametrize("family", ["Q"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_P_tp_built_in_mesh(family, degree, cell_type, datadir, cg_solver): +def test_P_tp_built_in_mesh(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.hexahedron: mesh = create_unit_cube(MPI.COMM_WORLD, 5, 5, 5, cell_type) elif cell_type == CellType.quadrilateral: @@ -602,7 +602,7 @@ def test_P_tp_built_in_mesh(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_tp @pytest.mark.parametrize("family", ["Q"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_vector_P_tp(family, degree, cell_type, datadir, cg_solver): +def test_vector_P_tp(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.hexahedron and degree == 4: pytest.skip("Skip expensive test on hexahedron") mesh = get_mesh(cell_type, datadir) @@ -615,7 +615,7 @@ def test_vector_P_tp(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_quad @pytest.mark.parametrize("family", ["DQ"]) @pytest.mark.parametrize("degree", [1, 2, 3]) -def test_dP_quad(family, degree, cell_type, datadir, cg_solver): +def test_dP_quad(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_dg_test(mesh, V, degree, cg_solver) @@ -625,7 +625,7 @@ def test_dP_quad(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_hex @pytest.mark.parametrize("family", ["DQ"]) @pytest.mark.parametrize("degree", [1, 2]) -def test_dP_hex(family, degree, cell_type, datadir, cg_solver): +def test_dP_hex(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_dg_test(mesh, V, degree, cg_solver) @@ -635,7 +635,7 @@ def test_dP_hex(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_tp @pytest.mark.parametrize("family", ["S"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_S_tp(family, degree, cell_type, datadir, cg_solver): +def test_S_tp(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_scalar_test(mesh, V, degree // 2, cg_solver) @@ -645,7 +645,7 @@ def test_S_tp(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_tp @pytest.mark.parametrize("family", ["S"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_S_tp_built_in_mesh(family, degree, cell_type, datadir, cg_solver): +def test_S_tp_built_in_mesh(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.hexahedron: mesh = create_unit_cube(MPI.COMM_WORLD, 5, 5, 5, cell_type) elif cell_type == CellType.quadrilateral: @@ -658,7 +658,7 @@ def test_S_tp_built_in_mesh(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_tp @pytest.mark.parametrize("family", ["S"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_vector_S_tp(family, degree, cell_type, datadir, cg_solver): +def test_vector_S_tp(family, degree, cell_type, datadir, cg_solver) -> None: if cell_type == CellType.hexahedron and degree == 4: pytest.skip("Skip expensive test on hexahedron") mesh = get_mesh(cell_type, datadir) @@ -671,7 +671,7 @@ def test_vector_S_tp(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_quad @pytest.mark.parametrize("family", ["DPC"]) @pytest.mark.parametrize("degree", [2, 3, 4]) -def test_DPC_quad(family, degree, cell_type, datadir, cg_solver): +def test_DPC_quad(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_dg_test(mesh, V, degree // 2, cg_solver) @@ -681,7 +681,7 @@ def test_DPC_quad(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_hex @pytest.mark.parametrize("family", ["DPC"]) @pytest.mark.parametrize("degree", [2]) -def test_DPC_hex(family, degree, cell_type, datadir, cg_solver): +def test_DPC_hex(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_dg_test(mesh, V, degree // 2, cg_solver) @@ -691,7 +691,7 @@ def test_DPC_hex(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_quad @pytest.mark.parametrize("family", ["RTCE", "RTCF"]) @pytest.mark.parametrize("degree", [1, 2, 3]) -def test_RTC_quad(family, degree, cell_type, datadir, cg_solver): +def test_RTC_quad(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_vector_test(mesh, V, degree - 1, cg_solver) @@ -701,7 +701,7 @@ def test_RTC_quad(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_hex @pytest.mark.parametrize("family", ["NCE", "NCF"]) @pytest.mark.parametrize("degree", [1, 2, 3]) -def test_NC_hex(family, degree, cell_type, datadir, cg_solver): +def test_NC_hex(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_vector_test(mesh, V, degree - 1, cg_solver, maxit=700, rtol=1e-4) @@ -711,7 +711,7 @@ def test_NC_hex(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_quad @pytest.mark.parametrize("family", ["BDMCE", "BDMCF"]) @pytest.mark.parametrize("degree", [1, 2, 3, 4]) -def test_BDM_quad(family, degree, cell_type, datadir, cg_solver): +def test_BDM_quad(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_vector_test(mesh, V, (degree - 1) // 2, cg_solver) @@ -721,7 +721,7 @@ def test_BDM_quad(family, degree, cell_type, datadir, cg_solver): @parametrize_cell_types_hex @pytest.mark.parametrize("family", ["AAE", "AAF"]) @pytest.mark.parametrize("degree", [1, 2, 3]) -def test_AA_hex(family, degree, cell_type, datadir, cg_solver): +def test_AA_hex(family, degree, cell_type, datadir, cg_solver) -> None: mesh = get_mesh(cell_type, datadir) V = functionspace(mesh, (family, degree)) run_vector_test(mesh, V, (degree - 1) // 2, cg_solver) diff --git a/python/test/unit/fem/test_forms.py b/python/test/unit/fem/test_forms.py index 9d8ad682060..a0526d61b69 100644 --- a/python/test/unit/fem/test_forms.py +++ b/python/test/unit/fem/test_forms.py @@ -31,7 +31,7 @@ ) -def test_extract_forms(): +def test_extract_forms() -> None: """Test extraction on unique function spaces for rows and columns of a block system. """ @@ -129,7 +129,7 @@ def test_incorrect_element(): dolfinx.fem.Form(f, msh, [incorrect_space, incorrect_space], ufcx_form, code) -def test_multiple_measures_one_subdomain_data(): +def test_multiple_measures_one_subdomain_data() -> None: comm = MPI.COMM_WORLD msh = dolfinx.mesh.create_unit_interval(comm, 10) x = SpatialCoordinate(msh) @@ -150,7 +150,7 @@ def test_multiple_measures_one_subdomain_data(): assert np.isclose(J_global, 1 / 3 + 1 / 2) -def test_derivative_block(): +def test_derivative_block() -> None: """Test the function derivative_block.""" msh = dolfinx.mesh.create_unit_interval(MPI.COMM_WORLD, 10) V0 = functionspace(msh, ("Lagrange", 1)) diff --git a/python/test/unit/fem/test_function.py b/python/test/unit/fem/test_function.py index 91c77a55cd2..8f1d2dfed49 100644 --- a/python/test/unit/fem/test_function.py +++ b/python/test/unit/fem/test_function.py @@ -44,7 +44,7 @@ def Q(mesh): return functionspace(mesh, ("Lagrange", 1, (gdim, gdim))) -def test_name_argument(W): +def test_name_argument(W) -> None: u = Function(W) v = Function(W, name="v") assert u.name == "f" @@ -52,7 +52,7 @@ def test_name_argument(W): assert str(v) == "v" -def test_copy(V): +def test_copy(V) -> None: u = Function(V) u.interpolate(lambda x: x[0] + 2 * x[1]) v = u.copy() @@ -84,7 +84,7 @@ def test_copy(V): ), ], ) -def test_eval(dtype): +def test_eval(dtype) -> None: xdtype = dtype(0).real.dtype mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3, dtype=xdtype) gdim = mesh.geometry.dim @@ -173,13 +173,13 @@ def test_eval_manifold(dtype): assert np.isclose(u.eval([0.75, 0.25, 0.5], 0)[0], 1.0, rtol=rtol) -def test_interpolation_mismatch_rank0(W): +def test_interpolation_mismatch_rank0(W) -> None: u = Function(W) with pytest.raises(ValueError): u.interpolate(lambda x: np.ones(x.shape[1])) -def test_interpolation_mismatch_rank1(W): +def test_interpolation_mismatch_rank1(W) -> None: u = Function(W) with pytest.raises(ValueError): u.interpolate(lambda x: np.ones((2, x.shape[1]))) @@ -208,7 +208,7 @@ def test_interpolation_mismatch_rank1(W): ), ], ) -def test_mixed_element_interpolation(dtype): +def test_mixed_element_interpolation(dtype) -> None: xdtype = dtype(0).real.dtype mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3, dtype=xdtype) el = element("Lagrange", mesh.basix_cell(), 1, dtype=xdtype) @@ -218,7 +218,7 @@ def test_mixed_element_interpolation(dtype): u.interpolate(lambda x: np.ones(2, x.shape[1])) -def test_interpolation_rank0(V): +def test_interpolation_rank0(V) -> None: class MyExpression: def __init__(self): self.t = 0.0 @@ -240,7 +240,7 @@ def eval(self, x): assert (w.x.array[:] == 2.0).all() # /NOSONAR -def test_interpolation_rank1(W): +def test_interpolation_rank1(W) -> None: def f(x): values = np.empty((3, x.shape[1])) values[0] = 1.0 @@ -322,7 +322,7 @@ def test_cffi_expression(dtype, cdtype): ), ], ) -def test_interpolation_function(dtype): +def test_interpolation_function(dtype) -> None: xdtype = dtype(0).real.dtype mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3, dtype=xdtype) V = functionspace(mesh, ("Lagrange", 1)) diff --git a/python/test/unit/fem/test_function_space.py b/python/test/unit/fem/test_function_space.py index 0351affa943..22920ccc3ea 100644 --- a/python/test/unit/fem/test_function_space.py +++ b/python/test/unit/fem/test_function_space.py @@ -63,7 +63,7 @@ def W2(g): return g.function_space -def test_python_interface(V, V2, W, W2, Q): +def test_python_interface(V, V2, W, W2, Q) -> None: # Test Python interface of cpp generated functionspace assert isinstance(V, FunctionSpace) assert isinstance(W, FunctionSpace) @@ -80,7 +80,7 @@ def test_python_interface(V, V2, W, W2, Q): assert V is V2 -def test_component(V, W, Q): +def test_component(V, W, Q) -> None: assert not W.component() assert not V.component() assert W.sub(0).component()[0] == 0 @@ -89,14 +89,14 @@ def test_component(V, W, Q): assert Q.sub(1).component()[0] == 1 -def test_equality(V, V2, W, W2): +def test_equality(V, V2, W, W2) -> None: assert V == V # /NOSONAR assert V == V2 assert W == W # /NOSONAR assert W == W2 -def test_sub(Q, W): +def test_sub(Q, W) -> None: X = Q.sub(0) with pytest.raises(IndexError): @@ -132,7 +132,7 @@ def test_sub(Q, W): assert W.element == X.element -def test_inclusion(V, Q): +def test_inclusion(V, Q) -> None: assert V.contains(V) assert not Q.contains(V) @@ -161,16 +161,16 @@ def test_inclusion(V, Q): assert not Q.sub(0).sub(0).contains(Q.sub(0).sub(1)) -def test_not_equal(W, V, W2, V2): +def test_not_equal(W, V, W2, V2) -> None: assert W != V assert W2 != V2 -def test_clone(W): +def test_clone(W) -> None: assert W.clone() is not W -def test_collapse(W, V): +def test_collapse(W, V) -> None: with pytest.raises(ValueError): Function(W.sub(1)) @@ -199,7 +199,7 @@ def test_collapse(W, V): assert f0.x.index_map.size_global == f1.x.index_map.size_global -def test_argument_equality(mesh, V, V2, W, W2): +def test_argument_equality(mesh, V, V2, W, W2) -> None: """Placed this test here because it's mainly about detecting differing function spaces. """ @@ -248,7 +248,7 @@ def test_argument_equality(mesh, V, V2, W, W2): assert grad(v) != grad(v3) -def test_cell_mismatch(mesh): +def test_cell_mismatch(mesh) -> None: """Test that cell mismatch raises early enough from UFL.""" e = element("P", "triangle", 1, dtype=default_real_type) with pytest.raises(BaseException): @@ -269,7 +269,7 @@ def test_basix_element(V, W, Q, V2): @pytest.mark.skip_in_parallel -def test_vector_function_space_cell_type(): +def test_vector_function_space_cell_type() -> None: """Test that the UFL element cell of a vector function space is correct on meshes where gdim > tdim. """ diff --git a/python/test/unit/fem/test_ghost_mesh_assembly.py b/python/test/unit/fem/test_ghost_mesh_assembly.py index ff331fe6191..5ebae11f9e7 100644 --- a/python/test/unit/fem/test_ghost_mesh_assembly.py +++ b/python/test/unit/fem/test_ghost_mesh_assembly.py @@ -40,7 +40,7 @@ def dS_from_ufl(mesh): ) @pytest.mark.parametrize("dx", [dx_from_ufl]) @pytest.mark.parametrize("ds", [ds_from_ufl]) -def test_ghost_mesh_assembly(mode, dx, ds): +def test_ghost_mesh_assembly(mode, dx, ds) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, ghost_mode=mode) V = functionspace(mesh, ("Lagrange", 1)) u, v = ufl.TrialFunction(V), ufl.TestFunction(V) @@ -103,7 +103,7 @@ def test_ghost_mesh_assembly(mode, dx, ds): ), ], ) -def test_ghost_mesh_dS_assembly(mode, dS, dtype): +def test_ghost_mesh_dS_assembly(mode, dS, dtype) -> None: xdtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, ghost_mode=mode, dtype=xdtype) V = functionspace(mesh, ("Lagrange", 1)) diff --git a/python/test/unit/fem/test_interpolate_geometry.py b/python/test/unit/fem/test_interpolate_geometry.py index e76248fa9da..a4681f549de 100644 --- a/python/test/unit/fem/test_interpolate_geometry.py +++ b/python/test/unit/fem/test_interpolate_geometry.py @@ -40,7 +40,7 @@ def _assert_close_up_to_row_permutation(a, b, atol): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_interpolate_geometry_p1_to_p2(dtype): +def test_interpolate_geometry_p1_to_p2(dtype) -> None: msh = create_unit_square(MPI.COMM_WORLD, 4, 4, dtype=dtype) cmap = coordinate_element(CellType.triangle, 2, dtype=dtype) @@ -64,7 +64,7 @@ def test_interpolate_geometry_p1_to_p2(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_interpolate_geometry_p1_roundtrip(dtype): +def test_interpolate_geometry_p1_roundtrip(dtype) -> None: msh = create_unit_square(MPI.COMM_WORLD, 4, 4, dtype=dtype) cmap = coordinate_element(CellType.triangle, 1, dtype=dtype) @@ -138,7 +138,7 @@ def transform(x): @pytest.mark.parametrize( "lagrange_variant", [LagrangeVariant.equispaced, LagrangeVariant.gll_isaac] ) -def test_curve_mesh(degree, dtype, R, cell_type, lagrange_variant): +def test_curve_mesh(degree, dtype, R, cell_type, lagrange_variant) -> None: Ns = [4, 8, 16, 32] errors = [_curve_mesh_errors(N, degree, dtype, R, cell_type, lagrange_variant) for N in Ns] @@ -178,7 +178,7 @@ def _discontinuous_cmap(cell_type, degree, dtype, variant=LagrangeVariant.gll_is @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("degree", [1, 2]) -def test_interpolate_geometry_discontinuous(dtype, degree): +def test_interpolate_geometry_discontinuous(dtype, degree) -> None: """A discontinuous coordinate element gives each cell its own nodes.""" msh = create_unit_square(MPI.COMM_WORLD, 4, 4, dtype=dtype) cmap = _discontinuous_cmap(basix.CellType.triangle, degree, dtype) @@ -210,7 +210,7 @@ def test_interpolate_geometry_discontinuous(dtype, degree): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_interpolate_geometry_discontinuous_assembly(dtype): +def test_interpolate_geometry_discontinuous_assembly(dtype) -> None: """Integrals over a discontinuous geometry, before and after moving cells.""" msh = create_unit_square(MPI.COMM_WORLD, 4, 4, dtype=dtype) new_msh = interpolate_geometry(msh, _discontinuous_cmap(basix.CellType.triangle, 1, dtype)) @@ -233,7 +233,7 @@ def total(measure, domain): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_interpolate_geometry_discontinuous_no_entity_geometry(dtype): +def test_interpolate_geometry_discontinuous_no_entity_geometry(dtype) -> None: """Sub-entity geometry is undefined for a discontinuous geometry.""" msh = create_unit_square(MPI.COMM_WORLD, 2, 2, dtype=dtype) new_msh = interpolate_geometry(msh, _discontinuous_cmap(basix.CellType.triangle, 1, dtype)) diff --git a/python/test/unit/fem/test_interpolation.py b/python/test/unit/fem/test_interpolation.py index 77d5698fe62..b07e4f4d376 100644 --- a/python/test/unit/fem/test_interpolation.py +++ b/python/test/unit/fem/test_interpolation.py @@ -274,7 +274,7 @@ def f(x): @pytest.mark.skip_in_parallel @parametrize_cell_types @pytest.mark.parametrize("order", range(1, 5)) -def test_Lagrange_interpolation(cell_type, order): +def test_Lagrange_interpolation(cell_type, order) -> None: """Test that interpolation is correct in a function space.""" mesh = one_cell_mesh(cell_type) V = functionspace(mesh, ("Lagrange", order)) @@ -286,7 +286,7 @@ def test_Lagrange_interpolation(cell_type, order): "cell_type", [CellType.interval, CellType.quadrilateral, CellType.hexahedron] ) @pytest.mark.parametrize("order", range(1, 5)) -def test_serendipity_interpolation(cell_type, order): +def test_serendipity_interpolation(cell_type, order) -> None: """Test that interpolation is correct in a function space.""" mesh = one_cell_mesh(cell_type) V = functionspace(mesh, ("S", order)) @@ -296,7 +296,7 @@ def test_serendipity_interpolation(cell_type, order): @pytest.mark.skip_in_parallel @parametrize_cell_types @pytest.mark.parametrize("order", range(1, 5)) -def test_vector_interpolation(cell_type, order): +def test_vector_interpolation(cell_type, order) -> None: """Test that interpolation is correct in a blocked (vector) function space.""" mesh = one_cell_mesh(cell_type) gdim = mesh.geometry.dim @@ -307,7 +307,7 @@ def test_vector_interpolation(cell_type, order): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("cell_type", [CellType.triangle, CellType.tetrahedron]) @pytest.mark.parametrize("order", range(1, 5)) -def test_N1curl_interpolation(cell_type, order): +def test_N1curl_interpolation(cell_type, order) -> None: random.seed(8) mesh = one_cell_mesh(cell_type) V = functionspace(mesh, ("Nedelec 1st kind H(curl)", order)) @@ -317,7 +317,7 @@ def test_N1curl_interpolation(cell_type, order): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("cell_type", [CellType.triangle]) @pytest.mark.parametrize("order", [1, 2]) -def test_N2curl_interpolation(cell_type, order): +def test_N2curl_interpolation(cell_type, order) -> None: mesh = one_cell_mesh(cell_type) V = functionspace(mesh, ("Nedelec 2nd kind H(curl)", order)) run_vector_test(V, order) @@ -326,7 +326,7 @@ def test_N2curl_interpolation(cell_type, order): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("cell_type", [CellType.quadrilateral]) @pytest.mark.parametrize("order", range(1, 5)) -def test_RTCE_interpolation(cell_type, order): +def test_RTCE_interpolation(cell_type, order) -> None: random.seed(8) mesh = one_cell_mesh(cell_type) V = functionspace(mesh, ("RTCE", order)) @@ -336,14 +336,14 @@ def test_RTCE_interpolation(cell_type, order): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("cell_type", [CellType.hexahedron]) @pytest.mark.parametrize("order", range(1, 5)) -def test_NCE_interpolation(cell_type, order): +def test_NCE_interpolation(cell_type, order) -> None: random.seed(8) mesh = one_cell_mesh(cell_type) V = functionspace(mesh, ("NCE", order)) run_vector_test(V, order - 1) -def test_mixed_sub_interpolation(): +def test_mixed_sub_interpolation() -> None: """Test interpolation of sub-functions.""" mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3) @@ -401,7 +401,7 @@ def f(x): @pytest.mark.skip_in_parallel -def test_mixed_interpolation(): +def test_mixed_interpolation() -> None: """Test that mixed interpolation raised an exception.""" mesh = one_cell_mesh(CellType.triangle) A = element("Lagrange", mesh.basix_cell(), 1, dtype=default_real_type) @@ -438,7 +438,7 @@ def test_mixed_interpolation(): ], ) @pytest.mark.parametrize("order2", [2, 3, 4]) -def test_interpolation_nedelec(order1, order2, dtype): +def test_interpolation_nedelec(order1, order2, dtype) -> None: xdtype = dtype(0).real.dtype mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2, dtype=xdtype) V = functionspace(mesh, ("N1curl", order1)) @@ -488,7 +488,7 @@ def test_interpolation_nedelec(order1, order2, dtype): ], ) @pytest.mark.parametrize("order", [1, 2, 3]) -def test_interpolation_dg_to_n1curl(tdim, order, dtype): +def test_interpolation_dg_to_n1curl(tdim, order, dtype) -> None: xdtype = dtype(0).real.dtype if tdim == 2: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, dtype=xdtype) @@ -529,7 +529,7 @@ def test_interpolation_dg_to_n1curl(tdim, order, dtype): ], ) @pytest.mark.parametrize("order", [1, 2, 3]) -def test_interpolation_n1curl_to_dg(tdim, order, dtype): +def test_interpolation_n1curl_to_dg(tdim, order, dtype) -> None: xdtype = dtype(0).real.dtype if tdim == 2: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, dtype=xdtype) @@ -570,7 +570,7 @@ def test_interpolation_n1curl_to_dg(tdim, order, dtype): ], ) @pytest.mark.parametrize("order", [1, 2, 3]) -def test_interpolation_n2curl_to_bdm(tdim, order, dtype): +def test_interpolation_n2curl_to_bdm(tdim, order, dtype) -> None: xdtype = dtype(0).real.dtype if tdim == 2: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, dtype=xdtype) @@ -611,7 +611,7 @@ def test_interpolation_n2curl_to_bdm(tdim, order, dtype): ], ) @pytest.mark.parametrize("order2", [1, 2, 3]) -def test_interpolation_p2p(order1, order2, dtype): +def test_interpolation_p2p(order1, order2, dtype) -> None: xdtype = dtype(0).real.dtype mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2, dtype=xdtype) V = functionspace(mesh, ("Lagrange", order1)) @@ -633,7 +633,7 @@ def test_interpolation_p2p(order1, order2, dtype): @pytest.mark.parametrize("order1", [1, 2, 3]) @pytest.mark.parametrize("order2", [1, 2]) -def test_interpolation_vector_elements(order1, order2): +def test_interpolation_vector_elements(order1, order2) -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) gdim = mesh.geometry.dim V = functionspace(mesh, ("Lagrange", order1, (gdim,))) @@ -742,7 +742,7 @@ def test_interpolation_non_affine_nonmatching_maps(): @pytest.mark.parametrize("order", [2, 3, 4]) @pytest.mark.parametrize("dim", [2, 3]) -def test_nedelec_spatial(order, dim): +def test_nedelec_spatial(order, dim) -> None: if dim == 2: mesh = create_unit_square(MPI.COMM_WORLD, 4, 4) elif dim == 3: @@ -773,7 +773,7 @@ def test_nedelec_spatial(order, dim): @pytest.mark.parametrize("order", [1, 2, 3, 4]) @pytest.mark.parametrize("dim", [2, 3]) @pytest.mark.parametrize("affine", [True, False]) -def test_vector_interpolation_spatial(order, dim, affine): +def test_vector_interpolation_spatial(order, dim, affine) -> None: if dim == 2: ct = CellType.triangle if affine else CellType.quadrilateral mesh = create_unit_square(MPI.COMM_WORLD, 3, 4, ct) @@ -792,7 +792,7 @@ def test_vector_interpolation_spatial(order, dim, affine): @pytest.mark.parametrize("order", [1, 2, 3, 4]) -def test_2D_lagrange_to_curl(order): +def test_2D_lagrange_to_curl(order) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 3, 4) V, W = functionspace(mesh, ("N1curl", order)), functionspace(mesh, ("Lagrange", order)) u, u0 = Function(V), Function(W) @@ -808,7 +808,7 @@ def test_2D_lagrange_to_curl(order): @pytest.mark.parametrize("order", [2, 3, 4]) -def test_de_rahm_2D(order): +def test_de_rahm_2D(order) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 3, 4) W = functionspace(mesh, ("Lagrange", order)) w = Function(W) @@ -868,7 +868,7 @@ def test_interpolate_subset(order, dim, affine, callable_): assert integral == pytest.approx(1 / (order + 1) * 0.5 ** (order + 1), abs=1.0e-6) -def test_interpolate_callable(): +def test_interpolate_callable() -> None: """Test interpolation with callables.""" numba = pytest.importorskip("numba") mesh = create_unit_square(MPI.COMM_WORLD, 2, 1) @@ -887,7 +887,7 @@ def f(x): @pytest.mark.parametrize("bound", [1.5, 0.5]) -def test_interpolate_callable_subset(bound): +def test_interpolate_callable_subset(bound) -> None: """Test interpolation on subsets with callables.""" mesh = create_unit_square(MPI.COMM_WORLD, 3, 4) cells = locate_entities(mesh, mesh.topology.dim, lambda x: x[1] <= bound + 1e-10) @@ -929,7 +929,7 @@ def test_interpolate_callable_subset(bound): ), ], ) -def test_vector_element_interpolation(scalar_element): +def test_vector_element_interpolation(scalar_element) -> None: """Test interpolation into a range of vector elements.""" mesh = create_unit_square( MPI.COMM_WORLD, 10, 10, getattr(CellType, scalar_element.cell.cellname) @@ -943,7 +943,7 @@ def test_vector_element_interpolation(scalar_element): assert np.allclose(u2.x.array, u.x.array) -def test_custom_vector_element(): +def test_custom_vector_element() -> None: """Test interpolation into an element with a value size that uses an identity map.""" mesh = create_unit_square(MPI.COMM_WORLD, 10, 10) wcoeffs = np.eye(6) @@ -988,7 +988,7 @@ def test_custom_vector_element(): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("cell_type", [CellType.triangle, CellType.tetrahedron]) @pytest.mark.parametrize("order", range(1, 5)) -def test_mixed_interpolation_permuting(cell_type, order): +def test_mixed_interpolation_permuting(cell_type, order) -> None: random.seed(8) mesh = two_cell_mesh(cell_type) @@ -1093,7 +1093,7 @@ def locate_bottom_facets(x): assert np.isclose(assemble_scalar(form(residual, dtype=xtype)), 0) -def test_interpolate_mismatched_dtype_raises(): +def test_interpolate_mismatched_dtype_raises() -> None: """Test that a Function of incompatible dtype reports the type error, rather than being mistaken for a callable f(x). """ @@ -1106,7 +1106,7 @@ def test_interpolate_mismatched_dtype_raises(): @pytest.mark.parametrize("xtype", [np.float64]) -def test_nonmatching_mesh_single_cell_overlap_interpolation(xtype): +def test_nonmatching_mesh_single_cell_overlap_interpolation(xtype) -> None: # mesh2 is contained by a single cell of mesh1. Here we test # interpolation when *not* every process has data to communicate diff --git a/python/test/unit/fem/test_manifold.py b/python/test/unit/fem/test_manifold.py index 9a683f5988a..97542a12224 100644 --- a/python/test/unit/fem/test_manifold.py +++ b/python/test/unit/fem/test_manifold.py @@ -128,7 +128,7 @@ def piola_id(spec): @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("spec", PIOLA_ELEMENTS, ids=piola_id) -def test_piola_element_value_shape(gdim, spec): +def test_piola_element_value_shape(gdim, spec) -> None: """``FiniteElement.value_shape`` must be the physical value shape. On a manifold it differs from the reference value shape that Basix @@ -148,7 +148,7 @@ def test_piola_element_value_shape(gdim, spec): "shape, symmetry", [((2,), None), ((3,), None), ((5,), None), ((3, 3), None), ((2, 2), True), ((3, 3), True)], ) -def test_blocked_value_shape_independent_of_gdim(gdim, shape, symmetry): +def test_blocked_value_shape_independent_of_gdim(gdim, shape, symmetry) -> None: """A blocked element's value shape is whatever the user asked for. Blocked elements are built from scalar, identity-mapped base @@ -167,7 +167,7 @@ def test_blocked_value_shape_independent_of_gdim(gdim, shape, symmetry): @pytest.mark.parametrize("gdim", [2, 3]) -def test_scalar_value_shape(gdim): +def test_scalar_value_shape(gdim) -> None: mesh = plane_mesh(1, gdim) el = element("Lagrange", "triangle", 1, dtype=default_real_type) V = functionspace(mesh, el) @@ -182,7 +182,7 @@ def test_scalar_value_shape(gdim): @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("spec", [s for s in PIOLA_ELEMENTS if s[2] == 1], ids=piola_id) -def test_interpolate_callable(gdim, spec): +def test_interpolate_callable(gdim, spec) -> None: """Interpolate a tangential constant field from a callable. The callable returns ``gdim`` components (one per physical @@ -205,7 +205,7 @@ def test_interpolate_callable(gdim, spec): @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("spec", PIOLA_ELEMENTS, ids=piola_id) -def test_interpolate_piola_to_dg(gdim, spec): +def test_interpolate_piola_to_dg(gdim, spec) -> None: """Interpolate a Piola-mapped Function into a (blocked) DG space. ``DG_k`` of the same degree contains the Piola space, so the @@ -234,7 +234,7 @@ def test_interpolate_piola_to_dg(gdim, spec): @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("families", [("RT", "BDM"), ("N1curl", "N2curl")]) -def test_interpolate_same_map(gdim, families): +def test_interpolate_same_map(gdim, families) -> None: """Interpolate between two elements sharing a map type. ``RT_1`` is contained in ``BDM_1`` and ``N1curl_1`` in ``N2curl_1``, @@ -254,7 +254,7 @@ def test_interpolate_same_map(gdim, families): @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("spec", [s for s in PIOLA_ELEMENTS if s[2] == 1], ids=piola_id) -def test_interpolate_expression(gdim, spec): +def test_interpolate_expression(gdim, spec) -> None: """Interpolate an ``Expression`` into a Piola-mapped space. ``Expression`` carries the UFL (physical) value shape, so on a @@ -277,7 +277,7 @@ def test_interpolate_expression(gdim, spec): @pytest.mark.parametrize("gdim", [2, 3]) -def test_interpolate_nonmatching_meshes(gdim): +def test_interpolate_nonmatching_meshes(gdim) -> None: """Interpolate a Piola-mapped Function between two manifold meshes. Both meshes triangulate the same embedded plane, so a tangential @@ -310,7 +310,7 @@ def test_interpolate_nonmatching_meshes(gdim): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("spec", [s for s in PIOLA_ELEMENTS if s[2] == 1], ids=piola_id) -def test_eval_piola(gdim, spec): +def test_eval_piola(gdim, spec) -> None: """``Function.eval`` returns ``gdim`` components on a manifold. ``Function::eval`` pushes the reference basis forward, so its output @@ -336,7 +336,7 @@ def test_eval_piola(gdim, spec): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("spec", [s for s in PIOLA_ELEMENTS if s[2] == 1], ids=piola_id) -def test_eval_piola_is_tangential(gdim, spec): +def test_eval_piola_is_tangential(gdim, spec) -> None: """Every value of a Piola-mapped field lies in the plane of its cell. The degrees of freedom are set directly, so this exercises @@ -369,7 +369,7 @@ def test_eval_piola_is_tangential(gdim, spec): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("gdim", [2, 3]) -def test_interpolation_matrix(gdim): +def test_interpolation_matrix(gdim) -> None: """The interpolation operator DG -> N1curl must act as interpolation. Applying the matrix to a tangential constant must give the @@ -393,7 +393,7 @@ def test_interpolation_matrix(gdim): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("gdim", [2, 3]) -def test_discrete_gradient(gdim): +def test_discrete_gradient(gdim) -> None: """``discrete_gradient`` maps a P1 field to the N1curl gradient. Regression guard: this operator is built purely from degrees of diff --git a/python/test/unit/fem/test_mixed_element.py b/python/test/unit/fem/test_mixed_element.py index a66a011e02a..6a7b228f0a3 100644 --- a/python/test/unit/fem/test_mixed_element.py +++ b/python/test/unit/fem/test_mixed_element.py @@ -20,7 +20,7 @@ @pytest.mark.parametrize("cell", [ufl.triangle, ufl.tetrahedron]) @pytest.mark.parametrize("degree", [1, 2]) @pytest.mark.parametrize("rank, family", [(0, "Lagrange"), (1, "Lagrange"), (1, "N1curl")]) -def test_mixed_element(rank, family, cell, degree): +def test_mixed_element(rank, family, cell, degree) -> None: if cell == ufl.triangle: mesh = create_unit_square( MPI.COMM_WORLD, 1, 1, CellType.triangle, ghost_mode=GhostMode.shared_facet @@ -48,7 +48,7 @@ def test_mixed_element(rank, family, cell, degree): @pytest.mark.skip_in_parallel -def test_vector_element(): +def test_vector_element() -> None: # Function space containing a scalar should work mesh = create_unit_square( MPI.COMM_WORLD, 1, 1, CellType.triangle, ghost_mode=GhostMode.shared_facet @@ -74,7 +74,7 @@ def test_vector_element(): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("d1", range(1, 4)) @pytest.mark.parametrize("d2", range(1, 4)) -def test_element_product(d1, d2): +def test_element_product(d1, d2) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 2, 2) P3 = element( "Lagrange", mesh.basix_cell(), d1, shape=(mesh.geometry.dim,), dtype=default_real_type @@ -100,7 +100,7 @@ def test_element_product(d1, d2): @pytest.mark.parametrize("rtype", [np.float32, np.float64]) -def test_single_element_in_mixed_element(rtype): +def test_single_element_in_mixed_element(rtype) -> None: """Check that a mixed element with a single element is equivalent to a single element.""" mesh = create_unit_square(MPI.COMM_WORLD, 10, 3, dtype=rtype) el = element("Lagrange", mesh.basix_cell(), 3, dtype=rtype) diff --git a/python/test/unit/fem/test_petsc_discrete_operators.py b/python/test/unit/fem/test_petsc_discrete_operators.py index cdb7614b8f2..040ad56c2ca 100644 --- a/python/test/unit/fem/test_petsc_discrete_operators.py +++ b/python/test/unit/fem/test_petsc_discrete_operators.py @@ -62,7 +62,7 @@ def test_gradient_petsc(self, mesh): "cell_type", [CellType.quadrilateral, CellType.triangle, CellType.tetrahedron, CellType.hexahedron], ) - def test_gradient_interpolation_petsc(self, cell_type, p, q): + def test_gradient_interpolation_petsc(self, cell_type, p, q) -> None: """Test discrete gradient computation with verification using Expression.""" from dolfinx.fem.petsc import discrete_gradient @@ -132,7 +132,7 @@ def test_gradient_interpolation_petsc(self, cell_type, p, q): "cell_type", [CellType.quadrilateral, CellType.triangle, CellType.tetrahedron, CellType.hexahedron], ) - def test_interpolation_matrix_petsc(self, cell_type, p, q, from_lagrange): + def test_interpolation_matrix_petsc(self, cell_type, p, q, from_lagrange) -> None: """Test that discrete interpolation matrix yields the same result as interpolation.""" from dolfinx.fem.petsc import interpolation_matrix diff --git a/python/test/unit/fem/test_petsc_matis.py b/python/test/unit/fem/test_petsc_matis.py index 6279a518fae..de698904843 100644 --- a/python/test/unit/fem/test_petsc_matis.py +++ b/python/test/unit/fem/test_petsc_matis.py @@ -56,7 +56,7 @@ def test_matis_matches_aij(cell_type, degree, shape): @pytest.mark.petsc4py -def test_matis_local_to_global_map(): +def test_matis_local_to_global_map() -> None: """The local-to-global maps share the matrix communicator. ``MatSetLocalToGlobalMapping_IS`` calls ``PetscCheckSameComm``. @@ -125,7 +125,7 @@ def test_blocked_matis(kind): @pytest.mark.petsc4py @pytest.mark.parametrize("kind", ["baij", "sbaij"]) -def test_square_block_type_rejected(kind): +def test_square_block_type_rejected(kind) -> None: """Block formats reject differing row and column block sizes. BAIJ and SBAIJ apply a single block size to both dimensions, so @@ -161,7 +161,7 @@ def test_square_block_type_accepted(kind): @pytest.mark.petsc4py -def test_matis_square_local_matrix(): +def test_matis_square_local_matrix() -> None: """A square, single-space form must give a square MATIS local matrix. The local-to-global maps set the local matrix dimensions, so they diff --git a/python/test/unit/fem/test_petsc_nonlinear_assembler.py b/python/test/unit/fem/test_petsc_nonlinear_assembler.py index 5cfaeaaf80d..6378fe94391 100644 --- a/python/test/unit/fem/test_petsc_nonlinear_assembler.py +++ b/python/test/unit/fem/test_petsc_nonlinear_assembler.py @@ -46,7 +46,7 @@ def nest_matrix_norm(A): class TestNLSPETSc: """Test nonlinear solver functionality with PETSc.""" - def test_matrix_assembly_block_nl(self): + def test_matrix_assembly_block_nl(self) -> None: """Test assembly of block matrices and vectors. Tests monolithic blocked structures, PETSc Nest structures, and @@ -215,7 +215,7 @@ def monolithic(): assert Anorm2 == pytest.approx(Anorm0, rtol_mono) assert bnorm2 == pytest.approx(bnorm0, rtol) - def test_assembly_solve_block_nl(self): + def test_assembly_solve_block_nl(self) -> None: """Solve a two-field nonlinear diffusion like problem with block matrix approaches and test that solution is the same. """ @@ -418,7 +418,7 @@ def monolithic_solve(): create_unit_cube(MPI.COMM_WORLD, 3, 5, 4, ghost_mode=GhostMode.shared_facet), ], ) - def test_assembly_solve_taylor_hood_nl(self, mesh): + def test_assembly_solve_taylor_hood_nl(self, mesh) -> None: """Assemble Stokes problem with Taylor-Hood elements and solve.""" from dolfinx.fem import petsc as fem_petsc diff --git a/python/test/unit/fem/test_problems.py b/python/test/unit/fem/test_problems.py index 5f71b9ff5ca..1144a70874e 100644 --- a/python/test/unit/fem/test_problems.py +++ b/python/test/unit/fem/test_problems.py @@ -32,7 +32,7 @@ ], ) @pytest.mark.skipif(not dolfinx.has_superlu_dist, reason="No SuperLU_DIST") -def test_superlu_problem(dtype): +def test_superlu_problem(dtype) -> None: """Manufactured Poisson and screened problem with exact solution u = x[1]**3.""" from dolfinx.fem.problems import LinearProblem @@ -79,7 +79,7 @@ def check_error(u_ex, uh): @pytest.mark.skipif(not dolfinx.has_superlu_dist, reason="No SuperLU_DIST") -def test_superlu_problem_default_args(): +def test_superlu_problem_default_args() -> None: from dolfinx.fem.problems import LinearProblem mesh = create_unit_square(MPI.COMM_WORLD, 5, 5) diff --git a/python/test/unit/fem/test_quadrature_elements.py b/python/test/unit/fem/test_quadrature_elements.py index 7c870a2f340..1b90da48a0c 100644 --- a/python/test/unit/fem/test_quadrature_elements.py +++ b/python/test/unit/fem/test_quadrature_elements.py @@ -15,7 +15,7 @@ @pytest.mark.parametrize("degree", range(1, 4)) -def test_default(degree): +def test_default(degree) -> None: msh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10) CG2_vect = dolfinx.fem.functionspace(msh, ("Lagrange", 1)) @@ -46,7 +46,7 @@ def test_default(degree): assert np.allclose(vol_v.array + sur_v.array, vol_surf.array) -def test_points_and_weights(): +def test_points_and_weights() -> None: msh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10) CG2_vect = dolfinx.fem.functionspace(msh, ("Lagrange", 1)) @@ -83,7 +83,7 @@ def test_points_and_weights(): @pytest.mark.parametrize("degree", range(1, 5)) -def test_interpolation(degree): +def test_interpolation(degree) -> None: msh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10) e = basix.ufl.quadrature_element(msh.topology.cell_name(), degree=degree) @@ -104,7 +104,7 @@ def test_interpolation(degree): @pytest.mark.parametrize("degree", range(1, 5)) -def test_interpolation_blocked(degree): +def test_interpolation_blocked(degree) -> None: msh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10) e = basix.ufl.quadrature_element(msh.topology.cell_name(), value_shape=(2,), degree=degree) @@ -140,7 +140,7 @@ def extract_diagonal(mat): @pytest.mark.parametrize("degree", range(1, 4)) @pytest.mark.parametrize("shape", [(), (1,), (2,), (3,), (4,), (2, 2), (3, 3)]) -def test_vector_element(shape, degree): +def test_vector_element(shape, degree) -> None: """Compare assembly into a vector with quadrature elements with the diagonal of an assembled mass matrix with the same quadrature element. """ @@ -172,7 +172,7 @@ def test_vector_element(shape, degree): @pytest.mark.parametrize("degree", range(1, 4)) -def test_quadrature_assembly(degree): +def test_quadrature_assembly(degree) -> None: """Test quadrature element against assembly with spatial coord and fixed quadrature rule.""" msh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 5, 7) dx_m = ufl.Measure( diff --git a/python/test/unit/fem/test_real_space.py b/python/test/unit/fem/test_real_space.py index a352caa525a..b372d50ae37 100644 --- a/python/test/unit/fem/test_real_space.py +++ b/python/test/unit/fem/test_real_space.py @@ -14,7 +14,7 @@ "cell_type", [dolfinx.mesh.CellType.triangle, dolfinx.mesh.CellType.quadrilateral] ) @pytest.mark.parametrize("dtype", [np.float64, np.float32]) -def test_real_function_space_mass(L, H, cell_type, dtype): +def test_real_function_space_mass(L, H, cell_type, dtype) -> None: """Test that real space mass matrix is the same as assembling the volume.""" mesh = dolfinx.mesh.create_rectangle( MPI.COMM_WORLD, [[0.0, 0.0], [L, H]], [7, 9], cell_type, dtype=dtype @@ -45,7 +45,7 @@ def test_real_function_space_mass(L, H, cell_type, dtype): @pytest.mark.parametrize( "cell_type", [dolfinx.mesh.CellType.tetrahedron, dolfinx.mesh.CellType.hexahedron] ) -def test_real_function_space_vector(cell_type, dtype): +def test_real_function_space_vector(cell_type, dtype) -> None: """Test assembling with real space test function is equal to assembling with a constant.""" mesh = dolfinx.mesh.create_unit_cube(MPI.COMM_WORLD, 2, 3, 5, cell_type, dtype=dtype) @@ -88,7 +88,7 @@ def test_real_function_space_vector(cell_type, dtype): pytest.param(np.float64, np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_complex_real_space(ftype, stype): +def test_complex_real_space(ftype, stype) -> None: mesh = dolfinx.mesh.create_unit_interval(MPI.COMM_WORLD, 13, dtype=ftype) val = (2 + 3j, -4 + 5j) @@ -122,7 +122,7 @@ def test_complex_real_space(ftype, stype): [np.float32, np.float64], ) @pytest.mark.parametrize("vs", [(3, 2), (2,), (), (1,)]) -def test_real_sub_spaces(vs, ftype): +def test_real_sub_spaces(vs, ftype) -> None: mesh = dolfinx.mesh.create_unit_square( MPI.COMM_WORLD, 4, 4, dolfinx.mesh.CellType.triangle, dtype=ftype @@ -154,7 +154,7 @@ def test_real_sub_spaces(vs, ftype): [np.float32, np.float64], ) @pytest.mark.parametrize("vs", [(3, 3), (2, 2), (), (1, 1), (6, 6)]) -def test_symmetric(vs, ftype): +def test_symmetric(vs, ftype) -> None: mesh = dolfinx.mesh.create_unit_square( MPI.COMM_WORLD, 4, 4, dolfinx.mesh.CellType.triangle, dtype=ftype diff --git a/python/test/unit/fem/test_special_functions.py b/python/test/unit/fem/test_special_functions.py index e3550de7030..12bb30f48a5 100644 --- a/python/test/unit/fem/test_special_functions.py +++ b/python/test/unit/fem/test_special_functions.py @@ -16,7 +16,7 @@ from dolfinx.mesh import create_unit_cube, create_unit_interval, create_unit_square -def test_facet_area1D(): +def test_facet_area1D() -> None: mesh = create_unit_interval(MPI.COMM_WORLD, 10) # NOTE: Area of a vertex is defined to 1 in ufl @@ -41,7 +41,7 @@ def test_facet_area1D(): # (MPI.COMM_WORLD, 3, 3, 3, CellType.hexahedron), 1. / 9) ], ) -def test_facet_area(mesh_factory): +def test_facet_area(mesh_factory) -> None: """Compute facet area of cell. UFL currently only supports affine cells for this computation. """ diff --git a/python/test/unit/fem/test_symmetric_tensor.py b/python/test/unit/fem/test_symmetric_tensor.py index 6b1fc8624d3..d76388d058b 100644 --- a/python/test/unit/fem/test_symmetric_tensor.py +++ b/python/test/unit/fem/test_symmetric_tensor.py @@ -17,7 +17,7 @@ @pytest.mark.parametrize("degree", range(1, 4)) @pytest.mark.parametrize("symmetry", [True, False]) -def test_transpose(degree, symmetry): +def test_transpose(degree, symmetry) -> None: mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10) e = basix.ufl.element( "Lagrange", @@ -35,7 +35,7 @@ def test_transpose(degree, symmetry): assert np.isclose(dolfinx.fem.assemble_scalar(form), 0) == symmetry -def test_interpolation(): +def test_interpolation() -> None: """Test that a symmetric 3x3 2-tensor is correctly interpolated.""" mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10) @@ -89,7 +89,7 @@ def tensor(x): ), ], ) -def test_interpolation_symmetric_tensor(dim, symmetry, etype, degree, dtype): +def test_interpolation_symmetric_tensor(dim, symmetry, etype, degree, dtype) -> None: """Tests the interpolation path for non-matching maps of symmetric elements.""" comm = MPI.COMM_WORLD real_type = dtype(0).real.dtype diff --git a/python/test/unit/fem/test_symmetry.py b/python/test/unit/fem/test_symmetry.py index 48e5a29650a..f36eac1ccf6 100644 --- a/python/test/unit/fem/test_symmetry.py +++ b/python/test/unit/fem/test_symmetry.py @@ -76,28 +76,28 @@ def run_symmetry_test(cell_type, e, form_f): @pytest.mark.skip_in_parallel @parametrize_elements @pytest.mark.parametrize("order", range(1, 2)) -def test_mass_matrix_dx(cell_type, family, order): +def test_mass_matrix_dx(cell_type, family, order) -> None: run_symmetry_test(cell_type, (family, order), lambda u, v: inner(u, v) * ufl.dx) @pytest.mark.skip_in_parallel @parametrize_lagrange_elements @pytest.mark.parametrize("order", range(1, 2)) -def test_stiffness_matrix_dx(cell_type, family, order): +def test_stiffness_matrix_dx(cell_type, family, order) -> None: run_symmetry_test(cell_type, (family, order), lambda u, v: inner(grad(u), grad(v)) * ufl.dx) @pytest.mark.skip_in_parallel @parametrize_elements @pytest.mark.parametrize("order", range(1, 2)) -def test_mass_matrix_ds(cell_type, family, order): +def test_mass_matrix_ds(cell_type, family, order) -> None: run_symmetry_test(cell_type, (family, order), lambda u, v: inner(u, v) * ufl.ds) @pytest.mark.skip_in_parallel @parametrize_lagrange_elements @pytest.mark.parametrize("order", range(1, 2)) -def test_stiffness_matrix_ds(cell_type, family, order): +def test_stiffness_matrix_ds(cell_type, family, order) -> None: run_symmetry_test(cell_type, (family, order), lambda u, v: inner(grad(u), grad(v)) * ufl.ds) @@ -105,7 +105,7 @@ def test_stiffness_matrix_ds(cell_type, family, order): @parametrize_elements @pytest.mark.parametrize("order", range(1, 2)) @pytest.mark.parametrize("sign", ["+", "-"]) -def test_mass_matrix_dS(cell_type, family, order, sign): +def test_mass_matrix_dS(cell_type, family, order, sign) -> None: run_symmetry_test(cell_type, (family, order), lambda u, v: inner(u, v)(sign) * ufl.dS) @@ -113,7 +113,7 @@ def test_mass_matrix_dS(cell_type, family, order, sign): @parametrize_lagrange_elements @pytest.mark.parametrize("order", range(1, 2)) @pytest.mark.parametrize("sign", ["+", "-"]) -def test_stiffness_matrix_dS(cell_type, family, order, sign): +def test_stiffness_matrix_dS(cell_type, family, order, sign) -> None: run_symmetry_test( cell_type, (family, order), lambda u, v: inner(grad(u), grad(v))(sign) * ufl.dS ) @@ -127,7 +127,7 @@ def test_stiffness_matrix_dS(cell_type, family, order, sign): @pytest.mark.parametrize("sign", ["+", "-"]) @pytest.mark.parametrize("order", range(1, 2)) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_mixed_element_form(cell_type, sign, order, dtype): +def test_mixed_element_form(cell_type, sign, order, dtype) -> None: if cell_type == CellType.triangle or cell_type == CellType.quadrilateral: mesh = create_unit_square(MPI.COMM_WORLD, 2, 2, cell_type, dtype=dtype) else: @@ -156,7 +156,7 @@ def test_mixed_element_form(cell_type, sign, order, dtype): @pytest.mark.parametrize("sign", ["+", "-"]) @pytest.mark.parametrize("order", range(1, 2)) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_mixed_element_vector_element_form(cell_type, sign, order, dtype): +def test_mixed_element_vector_element_form(cell_type, sign, order, dtype) -> None: if cell_type == CellType.triangle or cell_type == CellType.quadrilateral: mesh = create_unit_square(MPI.COMM_WORLD, 2, 2, cell_type, dtype=dtype) else: diff --git a/python/test/unit/fem/test_vector_assemble.py b/python/test/unit/fem/test_vector_assemble.py index 4dde3198604..8f98012e2ef 100644 --- a/python/test/unit/fem/test_vector_assemble.py +++ b/python/test/unit/fem/test_vector_assemble.py @@ -12,7 +12,7 @@ from dolfinx.mesh import create_unit_square -def test_vector_assemble_matrix_exterior(): +def test_vector_assemble_matrix_exterior() -> None: mesh = create_unit_square(MPI.COMM_WORLD, 3, 3) gdim = mesh.geometry.dim V = functionspace(mesh, ("Lagrange", 1, (gdim,))) @@ -22,7 +22,7 @@ def test_vector_assemble_matrix_exterior(): A.scatter_reverse() -def test_vector_assemble_matrix_interior(): +def test_vector_assemble_matrix_interior() -> None: mesh = create_unit_square(MPI.COMM_WORLD, 3, 3) gdim = mesh.geometry.dim V = functionspace(mesh, ("Lagrange", 1, (gdim,))) diff --git a/python/test/unit/fem/test_vector_function.py b/python/test/unit/fem/test_vector_function.py index 0d3661808b9..11be2db1e93 100644 --- a/python/test/unit/fem/test_vector_function.py +++ b/python/test/unit/fem/test_vector_function.py @@ -20,7 +20,7 @@ @pytest.mark.skip_in_parallel @pytest.mark.parametrize("space_type", ["RT"]) @pytest.mark.parametrize("order", [1, 2, 3, 4, 5]) -def test_div_conforming_triangle(space_type, order): +def test_div_conforming_triangle(space_type, order) -> None: """Checks that the vectors in div conforming spaces on a triangle are correctly oriented.""" # Create simple triangle mesh @@ -51,7 +51,7 @@ def perform_test(points, cells): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("space_type", ["RT"]) @pytest.mark.parametrize("order", [1, 2, 3, 4, 5]) -def test_div_conforming_tetrahedron(space_type, order): +def test_div_conforming_tetrahedron(space_type, order) -> None: """Checks that the vectors in div conforming spaces on a tetrahedron are correctly oriented.""" # Create simple tetrahedron cell mesh diff --git a/python/test/unit/geometry/test_bounding_box_tree.py b/python/test/unit/geometry/test_bounding_box_tree.py index 94181014014..e8388171fec 100644 --- a/python/test/unit/geometry/test_bounding_box_tree.py +++ b/python/test/unit/geometry/test_bounding_box_tree.py @@ -98,7 +98,7 @@ def find_colliding_cells(mesh, bbox, dtype, num_threads): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("padding", [True, False]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_padded_bbox(padding, dtype): +def test_padded_bbox(padding, dtype) -> None: """Test collision between two meshes separated by a distance of epsilon, and check if padding the mesh creates a possible collision. @@ -149,7 +149,7 @@ def rotation_matrix(axis, angle): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_empty_tree(dtype): +def test_empty_tree(dtype) -> None: mesh = create_unit_interval(MPI.COMM_WORLD, 16, dtype=dtype) bbtree = bb_tree(mesh, mesh.topology.dim, padding=0.0, entities=np.empty(0, dtype=dtype)) assert bbtree.num_bboxes == 0 @@ -157,7 +157,7 @@ def test_empty_tree(dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_collisions_point_1d(dtype): +def test_compute_collisions_point_1d(dtype) -> None: N = 16 p = np.array([0.3, 0, 0], dtype=dtype) mesh = create_unit_interval(MPI.COMM_WORLD, N, dtype=dtype) @@ -184,7 +184,7 @@ def test_compute_collisions_point_1d(dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("point", [np.array([0.52, 0, 0]), np.array([0.9, 0, 0])]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_collisions_tree_1d(point, dtype): +def test_compute_collisions_tree_1d(point, dtype) -> None: mesh_A = create_unit_interval(MPI.COMM_WORLD, 16, dtype=dtype) def locator_A(x): @@ -227,7 +227,7 @@ def locator_B(x): @pytest.mark.parametrize("num_threads", [1, 2]) @pytest.mark.parametrize("point", [np.array([0.52, 0.51, 0.0]), np.array([0.9, -0.9, 0.0])]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_collisions_tree_2d(point, dtype, num_threads): +def test_compute_collisions_tree_2d(point, dtype, num_threads) -> None: mesh_A = create_unit_square(MPI.COMM_WORLD, 3, 3, dtype=dtype) mesh_B = create_unit_square(MPI.COMM_WORLD, 5, 5, dtype=dtype) bgeom = mesh_B.geometry.x @@ -252,7 +252,7 @@ def test_compute_collisions_tree_2d(point, dtype, num_threads): @pytest.mark.parametrize("num_threads", [1, 2]) @pytest.mark.parametrize("point", [np.array([0.52, 0.51, 0.3]), np.array([0.9, -0.9, 0.3])]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_collisions_tree_3d(point, dtype, num_threads): +def test_compute_collisions_tree_3d(point, dtype, num_threads) -> None: M = 10 mesh_A = create_unit_cube(MPI.COMM_WORLD, M, M, M, dtype=dtype) mesh_B = create_unit_cube(MPI.COMM_WORLD, M, M, M, dtype=dtype) @@ -277,7 +277,7 @@ def test_compute_collisions_tree_3d(point, dtype, num_threads): @pytest.mark.parametrize("dim", [0, 1]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_closest_entity_1d(dim, dtype): +def test_compute_closest_entity_1d(dim, dtype) -> None: ref_distance = 0.75 N = 16 points = np.array([[-ref_distance, 0, 0], [2 / N, 2 * ref_distance, 0]], dtype=dtype) @@ -312,7 +312,7 @@ def test_compute_closest_entity_1d(dim, dtype): @pytest.mark.parametrize("dim", [0, 1, 2]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_closest_entity_2d(dim, dtype): +def test_compute_closest_entity_2d(dim, dtype) -> None: points = np.array([-1.0, -0.01, 0.0], dtype=dtype) mesh = create_unit_square(MPI.COMM_WORLD, 15, 15, dtype=dtype) mesh.topology.create_entities(dim) @@ -343,7 +343,7 @@ def test_compute_closest_entity_2d(dim, dtype): @pytest.mark.parametrize("dim", [1, 2, 3]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_closest_entity_3d(dim, dtype): +def test_compute_closest_entity_3d(dim, dtype) -> None: points = np.array([[0.9, 0, 1.135]], dtype=dtype) mesh = create_unit_cube(MPI.COMM_WORLD, 8, 8, 8, dtype=dtype) mesh.topology.create_entities(dim) @@ -373,7 +373,7 @@ def test_compute_closest_entity_3d(dim, dtype): @pytest.mark.parametrize("dim", [1, 2, 3]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_compute_closest_sub_entity(dim, dtype): +def test_compute_closest_sub_entity(dim, dtype) -> None: """Compute distance from subset of cells in a mesh to a point inside the mesh.""" ref_distance = 0.31 xc, yc, zc = 0.5, 0.5, 0.5 @@ -401,7 +401,7 @@ def test_compute_closest_sub_entity(dim, dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_surface_bbtree(dtype): +def test_surface_bbtree(dtype) -> None: """Test creation of BBTree on subset of entities(surface cells).""" mesh = create_unit_cube(MPI.COMM_WORLD, 8, 8, 8, dtype=dtype) mesh.topology.create_connectivity(mesh.topology.dim - 1, mesh.topology.dim) @@ -417,7 +417,7 @@ def test_surface_bbtree(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_sub_bbtree_codim1(dtype): +def test_sub_bbtree_codim1(dtype) -> None: """Testing point collision with a BoundingBoxTree of sub entities.""" mesh = create_unit_cube(MPI.COMM_WORLD, 4, 4, 4, cell_type=CellType.hexahedron, dtype=dtype) tdim = mesh.topology.dim @@ -449,7 +449,7 @@ def test_sub_bbtree_codim1(dtype): @pytest.mark.parametrize("comm", [MPI.COMM_WORLD, MPI.COMM_SELF]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_serial_global_bb_tree(dtype, comm): +def test_serial_global_bb_tree(dtype, comm) -> None: # Test if global bb tree with only one node returns the correct collision mesh = create_unit_cube(comm, 4, 5, 3) @@ -493,7 +493,7 @@ def test_sub_bbtree_box(ct, N, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_surface_bbtree_collision(dtype): +def test_surface_bbtree_collision(dtype) -> None: """Compute collision between two meshes, where only one cell of each mesh are colliding.""" tdim = 3 mesh1 = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3, CellType.hexahedron, dtype=dtype) @@ -520,7 +520,7 @@ def test_surface_bbtree_collision(dtype): @pytest.mark.parametrize("ct", [CellType.tetrahedron]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_shift_bbtree(ct, dtype): +def test_shift_bbtree(ct, dtype) -> None: tdim = 3 mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3, ct, dtype=dtype) bbtree = bb_tree(mesh, tdim, padding=0.0) @@ -541,7 +541,7 @@ def test_shift_bbtree(ct, dtype): @pytest.mark.parametrize("dim", [2, 3]) @pytest.mark.parametrize("affine", [True, False]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_determine_point_ownership(dim, affine, dtype): +def test_determine_point_ownership(dim, affine, dtype) -> None: """Find point owners (ranks and cells) using bounding box trees + global communication and compare to point ownership data results. """ diff --git a/python/test/unit/geometry/test_gjk.py b/python/test/unit/geometry/test_gjk.py index 9d32c7fe2bd..8762e80d14c 100644 --- a/python/test/unit/geometry/test_gjk.py +++ b/python/test/unit/geometry/test_gjk.py @@ -31,7 +31,7 @@ def distance_point_to_plane_3D(P1, P2, P3, point): @pytest.mark.parametrize("delta", [0.1, 1e-12, 0, -2]) @pytest.mark.parametrize("dtype", [np.float64, np.float32]) -def test_line_point_distance(delta, dtype): +def test_line_point_distance(delta, dtype) -> None: line = np.array([[0.1, 0.2, 0.3], [0.5, 0.8, 0.7]], dtype=dtype) point_on_line = line[0] + 0.27 * (line[1] - line[0]) normal = np.cross(line[0], line[1]) @@ -44,7 +44,7 @@ def test_line_point_distance(delta, dtype): @pytest.mark.parametrize("delta", [0.1, 1e-12, 0]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_line_line_distance(delta, dtype): +def test_line_line_distance(delta, dtype) -> None: line = np.array([[-0.5, -0.7, -0.3], [1, 2, 3]], dtype=dtype) point_on_line = line[0] + 0.38 * (line[1] - line[0]) normal = np.cross(line[0], line[1]) @@ -57,7 +57,7 @@ def test_line_line_distance(delta, dtype): @pytest.mark.parametrize("delta", [0.1 ** (3 * i) for i in range(6)]) @pytest.mark.parametrize("dtype", [np.float64]) -def test_tri_distance(delta, dtype): +def test_tri_distance(delta, dtype) -> None: tri_1 = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0]], dtype=dtype) tri_2 = np.array([[1, delta, 0], [3, 1.2, 0], [1, 1, 0]], dtype=dtype) P1 = tri_1[2] @@ -70,7 +70,7 @@ def test_tri_distance(delta, dtype): @pytest.mark.parametrize("delta", [0.1 * 0.1 ** (3 * i) for i in range(6)]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_quad_distance2d(delta, dtype): +def test_quad_distance2d(delta, dtype) -> None: quad_1 = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0]], dtype=dtype) quad_2 = np.array([[0, 1 + delta, 0], [2, 2, 0], [2, 4, 0], [4, 4, 0]], dtype=dtype) P1 = quad_1[2] @@ -82,7 +82,7 @@ def test_quad_distance2d(delta, dtype): @pytest.mark.parametrize("delta", [1 * 0.5 ** (3 * i) for i in range(7)]) -def test_tetra_distance_3d(delta): +def test_tetra_distance_3d(delta) -> None: tetra_1 = np.array([[0, 0, 0.2], [1, 0, 0.1], [0, 1, 0.3], [0, 0, 1]], dtype=np.float64) tetra_2 = np.array([[0, 0, -3], [1, 0, -3], [0, 1, -3], [0.5, 0.3, -delta]], dtype=np.float64) actual_distance = distance_point_to_plane_3D(tetra_1[0], tetra_1[1], tetra_1[2], tetra_2[3]) @@ -91,7 +91,7 @@ def test_tetra_distance_3d(delta): @pytest.mark.parametrize("delta", [(-1) ** i * np.sqrt(2) * 0.1 ** (3 * i) for i in range(6)]) -def test_tetra_collision_3d(delta): +def test_tetra_collision_3d(delta) -> None: tetra_1 = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=np.float64) tetra_2 = np.array([[0, 0, -3], [1, 0, -3], [0, 1, -3], [0.5, 0.3, -delta]], dtype=np.float64) actual_distance = distance_point_to_plane_3D(tetra_1[0], tetra_1[1], tetra_1[2], tetra_2[3]) @@ -103,7 +103,7 @@ def test_tetra_collision_3d(delta): @pytest.mark.parametrize("delta", [0, -0.1, -0.49, -0.51]) -def test_hex_collision_3d(delta): +def test_hex_collision_3d(delta) -> None: hex_1 = np.array( [[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1]], dtype=np.float64, @@ -131,7 +131,7 @@ def test_hex_collision_3d(delta): @pytest.mark.parametrize("delta", [1e8, 1.0, 1e-6, 1e-12]) @pytest.mark.parametrize("scale", [1000.0, 1.0, 1e-4]) @pytest.mark.parametrize("dtype", [np.float64]) -def test_cube_distance(delta, scale, dtype): +def test_cube_distance(delta, scale, dtype) -> None: cubes = [ scale * np.array( @@ -184,7 +184,7 @@ def test_cube_distance(delta, scale, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_collision_2nd_order_triangle(dtype): +def test_collision_2nd_order_triangle(dtype) -> None: points = np.array( [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [0.65, 0.65], [0.0, 0.5], [0.5, 0.0]], dtype=dtype ) diff --git a/python/test/unit/geometry/test_point_collision.py b/python/test/unit/geometry/test_point_collision.py index 2f64110b66c..691c772bdc3 100644 --- a/python/test/unit/geometry/test_point_collision.py +++ b/python/test/unit/geometry/test_point_collision.py @@ -10,7 +10,7 @@ @pytest.mark.skip_in_parallel # Skip in parallel as there is only one cell @pytest.mark.parametrize("find_closest_cell", [True, False]) -def test_determine_point_ownership(find_closest_cell): +def test_determine_point_ownership(find_closest_cell) -> None: comm = MPI.COMM_WORLD # Define mesh consiting of a single tetrahedron diff --git a/python/test/unit/graph/test_adjacencylist.py b/python/test/unit/graph/test_adjacencylist.py index 45fc2c9a285..ca72467311a 100644 --- a/python/test/unit/graph/test_adjacencylist.py +++ b/python/test/unit/graph/test_adjacencylist.py @@ -11,7 +11,7 @@ @pytest.mark.parametrize("dtype", [np.int32, np.int64]) -def test_create_adj2d(dtype): +def test_create_adj2d(dtype) -> None: data = np.zeros([2, 4], dtype=dtype) adj = adjacencylist(data) num_nodes, num_links = data.shape[0], data.shape[1] @@ -29,7 +29,7 @@ def test_create_adj2d(dtype): @pytest.mark.parametrize("dtype", [np.int32, np.int64]) -def test_equality_is_unhashable(dtype): +def test_equality_is_unhashable(dtype) -> None: """Structurally equal adjacency lists must not have identity hashes.""" data = np.array([[1, 2], [0, 2]], dtype=dtype) adj0 = adjacencylist(data) diff --git a/python/test/unit/io/test_adios2.py b/python/test/unit/io/test_adios2.py index 0b7bc961d97..581257f0a5b 100644 --- a/python/test/unit/io/test_adios2.py +++ b/python/test/unit/io/test_adios2.py @@ -65,7 +65,7 @@ def test_second_order_vtx(self, tempdir): @pytest.mark.parametrize("dim", [2, 3]) @pytest.mark.parametrize("simplex", [True, False]) - def test_vtx_mesh(self, tempdir, dim, simplex): + def test_vtx_mesh(self, tempdir, dim, simplex) -> None: """Test saving mesh with VTXWriter.""" from dolfinx.io import VTXWriter @@ -78,7 +78,7 @@ def test_vtx_mesh(self, tempdir, dim, simplex): @pytest.mark.parametrize("dim", [2, 3]) @pytest.mark.parametrize("simplex", [True, False]) - def test_vtx_functions_fail(self, tempdir, dim, simplex): + def test_vtx_functions_fail(self, tempdir, dim, simplex) -> None: """Test for error when elements differ.""" from dolfinx.io import VTXWriter @@ -92,7 +92,7 @@ def test_vtx_functions_fail(self, tempdir, dim, simplex): @pytest.mark.parametrize("dim", [2, 3]) @pytest.mark.parametrize("simplex", [True, False]) - def test_vtx_names_fail(self, tempdir, dim, simplex): + def test_vtx_names_fail(self, tempdir, dim, simplex) -> None: """Test for error when elements differ.""" from dolfinx.io import VTXWriter @@ -105,7 +105,7 @@ def test_vtx_names_fail(self, tempdir, dim, simplex): VTXWriter(mesh.comm, filename, [v, w]) @pytest.mark.parametrize("simplex", [True, False]) - def test_vtx_different_meshes_function(self, tempdir, simplex): + def test_vtx_different_meshes_function(self, tempdir, simplex) -> None: """Test for error when functions do not share a mesh.""" from dolfinx.io import VTXWriter @@ -120,7 +120,7 @@ def test_vtx_different_meshes_function(self, tempdir, simplex): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) @pytest.mark.parametrize("dim", [2, 3]) @pytest.mark.parametrize("simplex", [True, False]) - def test_vtx_functions(self, tempdir, dtype, dim, simplex): + def test_vtx_functions(self, tempdir, dtype, dim, simplex) -> None: """Test saving high order Lagrange functions.""" from dolfinx.io import VTXWriter @@ -161,7 +161,7 @@ def vel(x): f.close() - def test_save_vtkx_cell_point(self, tempdir): + def test_save_vtkx_cell_point(self, tempdir) -> None: """Test writing point-wise data.""" from dolfinx.io import VTXWriter @@ -178,7 +178,7 @@ def test_save_vtkx_cell_point(self, tempdir): f.write(0) f.close() - def test_empty_rank_mesh(self, tempdir): + def test_empty_rank_mesh(self, tempdir) -> None: """Test VTXWriter on mesh where some ranks have no cells.""" from dolfinx.io import VTXWriter @@ -212,7 +212,7 @@ def partitioner(comm, nparts, dual_graph, cell_weights, edge_weights, ghosting): @pytest.mark.parametrize("dim", [2, 3]) @pytest.mark.parametrize("simplex", [True, False]) @pytest.mark.parametrize("reuse", [True, False]) - def test_vtx_reuse_mesh(self, tempdir, dim, simplex, reuse): + def test_vtx_reuse_mesh(self, tempdir, dim, simplex, reuse) -> None: """Test reusage of mesh by VTXWriter.""" from dolfinx.io import VTXMeshPolicy, VTXWriter @@ -249,7 +249,7 @@ def test_vtx_reuse_mesh(self, tempdir, dim, simplex, reuse): assert int(var["AvailableStepsCount"]) == target_all adios_file.close() - def test_dg_0_data(self, tempdir): + def test_dg_0_data(self, tempdir) -> None: """Test that we can mix DG-0 and other Lagrange functions.""" from dolfinx.io import VTXWriter diff --git a/python/test/unit/io/test_gmsh.py b/python/test/unit/io/test_gmsh.py index 308b04b305c..0f706e630a1 100644 --- a/python/test/unit/io/test_gmsh.py +++ b/python/test/unit/io/test_gmsh.py @@ -19,7 +19,7 @@ pytest.param(3, marks=pytest.mark.xfail(raises=RuntimeError)), ], ) -def test_physical_tags(marker_mode): +def test_physical_tags(marker_mode) -> None: """Test that we catch partially tagged meshes and not tagged meshes as errors. """ diff --git a/python/test/unit/io/test_vtk.py b/python/test/unit/io/test_vtk.py index 3e56300886d..1cf54fc6b66 100644 --- a/python/test/unit/io/test_vtk.py +++ b/python/test/unit/io/test_vtk.py @@ -31,7 +31,7 @@ cell_types_3D = [CellType.tetrahedron, CellType.hexahedron] -def test_save_1d_mesh_subdir(tempdir): +def test_save_1d_mesh_subdir(tempdir) -> None: filename = Path(tempdir, "mesh.pvd") mesh = create_unit_interval(MPI.COMM_WORLD, 32) with VTKFile(MPI.COMM_WORLD, filename, "w") as vtk: @@ -40,7 +40,7 @@ def test_save_1d_mesh_subdir(tempdir): @pytest.mark.parametrize("cell_type", cell_types_2D) -def test_save_2d_mesh(tempdir, cell_type): +def test_save_2d_mesh(tempdir, cell_type) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 32, 32, cell_type=cell_type) filename = Path(tempdir, f"mesh_{cell_type.name}.pvd") with VTKFile(MPI.COMM_WORLD, filename, "w") as vtk: @@ -49,7 +49,7 @@ def test_save_2d_mesh(tempdir, cell_type): @pytest.mark.parametrize("cell_type", cell_types_3D) -def test_save_3d_mesh(tempdir, cell_type): +def test_save_3d_mesh(tempdir, cell_type) -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 8, 8, 8, cell_type=cell_type) filename = Path(tempdir, f"mesh_{cell_type.name}.pvd") with VTKFile(MPI.COMM_WORLD, filename, "w") as vtk: @@ -57,7 +57,7 @@ def test_save_3d_mesh(tempdir, cell_type): vtk.write_mesh(mesh, 2.0) -def test_save_1d_scalar(tempdir): +def test_save_1d_scalar(tempdir) -> None: mesh = create_unit_interval(MPI.COMM_WORLD, 32) u = Function(functionspace(mesh, ("Lagrange", 2))) u.interpolate(lambda x: x[0]) @@ -67,7 +67,7 @@ def test_save_1d_scalar(tempdir): @pytest.mark.parametrize("cell_type", cell_types_2D) -def test_save_2d_scalar(tempdir, cell_type): +def test_save_2d_scalar(tempdir, cell_type) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, cell_type=cell_type) u = Function(functionspace(mesh, ("Lagrange", 2))) u.x.array[:] = 1.0 @@ -79,7 +79,7 @@ def test_save_2d_scalar(tempdir, cell_type): @pytest.mark.parametrize("cell_type", cell_types_3D) -def test_save_3d_scalar(tempdir, cell_type): +def test_save_3d_scalar(tempdir, cell_type) -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 8, 8, 8, cell_type=cell_type) u = Function(functionspace(mesh, ("Lagrange", 2))) u.x.array[:] = 1.0 @@ -90,7 +90,7 @@ def test_save_3d_scalar(tempdir, cell_type): vtk.write_function(u, 1.0) -def test_save_1d_vector(tempdir): +def test_save_1d_vector(tempdir) -> None: mesh = create_unit_interval(MPI.COMM_WORLD, 32) def f(x): @@ -108,7 +108,7 @@ def f(x): @pytest.mark.parametrize("cell_type", cell_types_2D) -def test_save_2d_vector(tempdir, cell_type): +def test_save_2d_vector(tempdir, cell_type) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, cell_type=cell_type) gdim = mesh.geometry.dim u = Function(functionspace(mesh, ("Lagrange", 1, (gdim,)))) @@ -127,7 +127,7 @@ def f(x): @pytest.mark.skip_in_parallel -def test_save_2d_vector_CG2(tempdir): +def test_save_2d_vector_CG2(tempdir) -> None: points = np.array( [[0, 0], [1, 0], [0, 2], [0.5, 1], [0, 1], [0.5, 0], [1, 2], [0.5, 2], [1, 1]], dtype=default_real_type, @@ -143,7 +143,7 @@ def test_save_2d_vector_CG2(tempdir): vtk.write_function(u, 0.0) -def test_save_vtk_mixed(tempdir): +def test_save_vtk_mixed(tempdir) -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3) P2 = element( "Lagrange", mesh.basix_cell(), 1, shape=(mesh.geometry.dim,), dtype=default_real_type @@ -180,7 +180,7 @@ def test_save_vtk_mixed(tempdir): @pytest.mark.parametrize("cell_type", cell_types_2D) -def test_save_vector_element(tempdir, cell_type): +def test_save_vector_element(tempdir, cell_type) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, cell_type=cell_type) u = Function(functionspace(mesh, ("RT", 1))) @@ -218,7 +218,7 @@ def test_save_vtk_cell_point(tempdir): vtk.write_function((U1, U2), 0.0) -def test_save_1d_tensor(tempdir): +def test_save_1d_tensor(tempdir) -> None: mesh = create_unit_interval(MPI.COMM_WORLD, 32) e = element("Lagrange", mesh.basix_cell(), 2, shape=(2, 2), dtype=default_real_type) u = Function(functionspace(mesh, e)) @@ -228,7 +228,7 @@ def test_save_1d_tensor(tempdir): vtk.write_function(u, 0.0) -def test_save_2d_tensor(tempdir): +def test_save_2d_tensor(tempdir) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 16, 16) gdim = mesh.geometry.dim u = Function(functionspace(mesh, ("Lagrange", 2, (gdim, gdim)))) @@ -240,7 +240,7 @@ def test_save_2d_tensor(tempdir): vtk.write_function(u, 1.0) -def test_save_3d_tensor(tempdir): +def test_save_3d_tensor(tempdir) -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 8, 8, 8) gdim = mesh.geometry.dim u = Function(functionspace(mesh, ("Lagrange", 2, (gdim, gdim)))) @@ -250,7 +250,7 @@ def test_save_3d_tensor(tempdir): vtk.write_function(u, 0.0) -def test_triangle_perm_vtk(): +def test_triangle_perm_vtk() -> None: higher_order_triangle_perm = { 10: np.array([0, 1, 2, 5, 6, 8, 7, 3, 4, 9]), 15: np.array([0, 1, 2, 6, 7, 8, 11, 10, 9, 3, 4, 5, 12, 13, 14]), @@ -441,7 +441,7 @@ def test_triangle_perm_vtk(): assert_array_equal(v, v_test) -def test_vtk_mesh(): +def test_vtk_mesh() -> None: comm = MPI.COMM_WORLD mesh = create_unit_square(comm, 2 * comm.size, 2 * comm.size) V = functionspace(mesh, ("Lagrange", 1)) diff --git a/python/test/unit/io/test_vtkhdf.py b/python/test/unit/io/test_vtkhdf.py index 347a176bfa4..eb2d3c03a97 100644 --- a/python/test/unit/io/test_vtkhdf.py +++ b/python/test/unit/io/test_vtkhdf.py @@ -15,7 +15,7 @@ from dolfinx.mesh import CellType, Mesh, create_unit_cube, create_unit_square -def test_read_write_vtkhdf_mesh2d(): +def test_read_write_vtkhdf_mesh2d() -> None: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, dtype=np.float32) write_mesh("example2d.vtkhdf", mesh) mesh2 = read_mesh(MPI.COMM_WORLD, "example2d.vtkhdf", np.float32) @@ -25,7 +25,7 @@ def test_read_write_vtkhdf_mesh2d(): assert mesh.topology.index_map(2).size_global == mesh2.topology.index_map(2).size_global -def test_read_write_vtkhdf_mesh3d(): +def test_read_write_vtkhdf_mesh3d() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 5, 5, 5, cell_type=CellType.prism) write_mesh("example3d.vtkhdf", mesh) mesh2 = read_mesh(MPI.COMM_WORLD, "example3d.vtkhdf") @@ -34,7 +34,7 @@ def test_read_write_vtkhdf_mesh3d(): @pytest.mark.parametrize("num_threads", [1, 4]) -def test_read_write_vtkhdf_num_threads(num_threads): +def test_read_write_vtkhdf_num_threads(num_threads) -> None: filename = "example_num_threads.vtkhdf" mesh = create_unit_cube(MPI.COMM_WORLD, 4, 3, 5) write_mesh(filename, mesh) @@ -64,7 +64,7 @@ def test_read_write_vtkhdf_num_threads(num_threads): assert np.isclose(vol_1, vol_n) -def test_read_vtkhdf_num_threads_invalid(): +def test_read_vtkhdf_num_threads_invalid() -> None: filename = "example_num_threads_invalid.vtkhdf" mesh = create_unit_square(MPI.COMM_WORLD, 4, 4) write_mesh(filename, mesh) @@ -73,7 +73,7 @@ def test_read_vtkhdf_num_threads_invalid(): read_mesh(MPI.COMM_WORLD, filename, num_threads=0) -def test_read_write_mixed_topology(mixed_topology_mesh): +def test_read_write_mixed_topology(mixed_topology_mesh) -> None: mesh = Mesh(mixed_topology_mesh, None) write_mesh("mixed_mesh.vtkhdf", mesh) @@ -157,7 +157,7 @@ def test_read_write_higher_order(): @pytest.mark.parametrize("order", [1, 2, 3]) -def test_read_write_higher_order_mesh(order): +def test_read_write_higher_order_mesh(order) -> None: try: import gmsh except ImportError: @@ -236,7 +236,7 @@ def test_read_write_higher_order_mesh(order): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_write_point_data(dtype): +def test_write_point_data(dtype) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, dtype=dtype) filename = "point_data.vtkhdf" write_mesh(filename, mesh) @@ -247,7 +247,7 @@ def test_write_point_data(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("width", [1, 3]) -def test_write_cell_data(dtype, width): +def test_write_cell_data(dtype, width) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, dtype=dtype) filename = "cell_data.vtkhdf" write_mesh(filename, mesh) @@ -256,7 +256,7 @@ def test_write_cell_data(dtype, width): write_cell_data(filename, mesh, cell_data, float(j)) -def test_write_mixed_topology_data(mixed_topology_mesh): +def test_write_mixed_topology_data(mixed_topology_mesh) -> None: mesh = Mesh(mixed_topology_mesh, None) filename = "mixed_point_data.vtkhdf" write_mesh(filename, mesh) diff --git a/python/test/unit/io/test_xdmf_function.py b/python/test/unit/io/test_xdmf_function.py index 4a99d82a88c..553fa0d6114 100644 --- a/python/test/unit/io/test_xdmf_function.py +++ b/python/test/unit/io/test_xdmf_function.py @@ -44,7 +44,7 @@ def mesh_factory(tdim, n): @pytest.mark.parametrize("use_pathlib", [True, False]) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.double, np.complex128]) -def test_save_1d_scalar(tempdir, encoding, dtype, use_pathlib): +def test_save_1d_scalar(tempdir, encoding, dtype, use_pathlib) -> None: xtype = np.real(dtype(0)).dtype filename2 = Path(tempdir).joinpath("u1_.xdmf") if use_pathlib else Path(tempdir, "u1_.xdmf") mesh = create_unit_interval(MPI.COMM_WORLD, 32, dtype=xtype) @@ -68,7 +68,7 @@ def test_save_1d_scalar(tempdir, encoding, dtype, use_pathlib): @pytest.mark.parametrize("cell_type", celltypes_2D) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.double, np.complex128]) -def test_save_2d_scalar(tempdir, encoding, dtype, cell_type): +def test_save_2d_scalar(tempdir, encoding, dtype, cell_type) -> None: xtype = np.real(dtype(0)).dtype filename = Path(tempdir, "u2.xdmf") mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, cell_type, dtype=xtype) @@ -102,7 +102,7 @@ def test_save_2d_scalar(tempdir, encoding, dtype, cell_type): @pytest.mark.parametrize("cell_type", celltypes_3D) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.double, np.complex128]) -def test_save_3d_scalar(tempdir, encoding, dtype, cell_type): +def test_save_3d_scalar(tempdir, encoding, dtype, cell_type) -> None: xtype = np.real(dtype(0)).dtype filename = Path(tempdir, "u3.xdmf") mesh = create_unit_cube(MPI.COMM_WORLD, 4, 3, 4, cell_type, dtype=xtype) @@ -121,7 +121,7 @@ def test_save_3d_scalar(tempdir, encoding, dtype, cell_type): @pytest.mark.parametrize("cell_type", celltypes_2D) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.double, np.complex128]) -def test_save_2d_vector(tempdir, encoding, dtype, cell_type): +def test_save_2d_vector(tempdir, encoding, dtype, cell_type) -> None: xtype = np.real(dtype(0)).dtype filename = Path(tempdir, "u_2dv.xdmf") mesh = create_unit_square(MPI.COMM_WORLD, 12, 13, cell_type, dtype=xtype) @@ -142,7 +142,7 @@ def test_save_2d_vector(tempdir, encoding, dtype, cell_type): @pytest.mark.parametrize("cell_type", celltypes_3D) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.double, np.complex128]) -def test_save_3d_vector(tempdir, encoding, dtype, cell_type): +def test_save_3d_vector(tempdir, encoding, dtype, cell_type) -> None: xtype = np.real(dtype(0)).dtype filename = Path(tempdir, "u_3Dv.xdmf") mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2, cell_type, dtype=xtype) @@ -170,7 +170,7 @@ def test_save_3d_vector(tempdir, encoding, dtype, cell_type): @pytest.mark.parametrize("cell_type", celltypes_2D) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.double, np.complex128]) -def test_save_2d_tensor(tempdir, encoding, dtype, cell_type): +def test_save_2d_tensor(tempdir, encoding, dtype, cell_type) -> None: xtype = np.real(dtype(0)).dtype filename = Path(tempdir, "tensor.xdmf") mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, cell_type, dtype=xtype) @@ -188,7 +188,7 @@ def test_save_2d_tensor(tempdir, encoding, dtype, cell_type): @pytest.mark.parametrize("cell_type", celltypes_3D) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_save_3d_tensor(tempdir, encoding, dtype, cell_type): +def test_save_3d_tensor(tempdir, encoding, dtype, cell_type) -> None: xtype = np.real(dtype(0)).dtype filename = Path(tempdir, "u3t.xdmf") mesh = create_unit_cube(MPI.COMM_WORLD, 4, 4, 4, cell_type, dtype=xtype) @@ -207,7 +207,7 @@ def test_save_3d_tensor(tempdir, encoding, dtype, cell_type): @pytest.mark.parametrize("cell_type", celltypes_3D) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_save_3d_vector_series(tempdir, encoding, dtype, cell_type): +def test_save_3d_vector_series(tempdir, encoding, dtype, cell_type) -> None: filename = Path(tempdir, "u_3D.xdmf") xtype = np.real(dtype(0)).dtype mesh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2, cell_type, dtype=xtype) @@ -224,7 +224,7 @@ def test_save_3d_vector_series(tempdir, encoding, dtype, cell_type): file.write_function(u, 0.3) -def test_higher_order_function(tempdir): +def test_higher_order_function(tempdir) -> None: """Test Function output for higher-order meshes.""" gmsh = pytest.importorskip("gmsh") diff --git a/python/test/unit/io/test_xdmf_mesh.py b/python/test/unit/io/test_xdmf_mesh.py index 28b064864ca..ed74fe7f988 100644 --- a/python/test/unit/io/test_xdmf_mesh.py +++ b/python/test/unit/io/test_xdmf_mesh.py @@ -51,7 +51,7 @@ def mesh_factory(tdim, n, ghost_mode=GhostMode.shared_facet, dtype=default_real_ @pytest.mark.skipif(default_real_type != np.float64, reason="float32 not supported yet") @pytest.mark.parametrize("encoding", encodings) -def test_save_and_load_1d_mesh(tempdir, encoding): +def test_save_and_load_1d_mesh(tempdir, encoding) -> None: filename = Path(tempdir, "mesh.xdmf") mesh = create_unit_interval(MPI.COMM_WORLD, 32) with XDMFFile(mesh.comm, filename, "w", encoding=encoding) as file: @@ -68,7 +68,7 @@ def test_save_and_load_1d_mesh(tempdir, encoding): @pytest.mark.skipif(default_real_type != np.float64, reason="float32 not supported yet") @pytest.mark.parametrize("cell_type", celltypes_2D) @pytest.mark.parametrize("encoding", encodings) -def test_save_and_load_2d_mesh(tempdir, encoding, cell_type): +def test_save_and_load_2d_mesh(tempdir, encoding, cell_type) -> None: filename = Path(tempdir, "mesh.xdmf") mesh = create_unit_square(MPI.COMM_WORLD, 12, 12, cell_type) mesh.name = "square" @@ -91,7 +91,7 @@ def test_save_and_load_2d_mesh(tempdir, encoding, cell_type): @pytest.mark.skipif(default_real_type != np.float64, reason="float32 not supported yet") @pytest.mark.parametrize("cell_type", celltypes_3D) @pytest.mark.parametrize("encoding", encodings) -def test_save_and_load_3d_mesh(tempdir, encoding, cell_type): +def test_save_and_load_3d_mesh(tempdir, encoding, cell_type) -> None: filename = Path(tempdir, "mesh.xdmf") mesh = create_unit_cube(MPI.COMM_WORLD, 12, 12, 8, cell_type) with XDMFFile(mesh.comm, filename, "w", encoding=encoding) as file: @@ -109,7 +109,7 @@ def test_save_and_load_3d_mesh(tempdir, encoding, cell_type): @pytest.mark.parametrize("num_threads", [1, 4]) -def test_read_write_num_threads(tempdir, num_threads): +def test_read_write_num_threads(tempdir, num_threads) -> None: filename = Path(tempdir, "mesh_num_threads.xdmf") mesh = create_unit_cube(MPI.COMM_WORLD, 4, 4, 4) with XDMFFile(mesh.comm, filename, "w") as file: @@ -213,7 +213,7 @@ def test_read_write_p2_mesh(tempdir, encoding): @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) @pytest.mark.parametrize("encoding", encodings) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_submesh(tempdir, d, n, codim, ghost_mode, encoding, dtype): +def test_submesh(tempdir, d, n, codim, ghost_mode, encoding, dtype) -> None: mesh = mesh_factory(d, n, ghost_mode, dtype=dtype) edim = d - codim entities = locate_entities(mesh, edim, lambda x: x[0] > 0.4999) diff --git a/python/test/unit/io/test_xdmf_meshdata.py b/python/test/unit/io/test_xdmf_meshdata.py index 0d98c468ace..228953eff99 100644 --- a/python/test/unit/io/test_xdmf_meshdata.py +++ b/python/test/unit/io/test_xdmf_meshdata.py @@ -39,7 +39,7 @@ def mesh_factory(tdim, n): @pytest.mark.skipif(default_real_type != np.float64, reason="float32 not supported yet") @pytest.mark.parametrize("tdim", [2, 3]) @pytest.mark.parametrize("n", [6]) -def test_read_mesh_data(tempdir, tdim, n): +def test_read_mesh_data(tempdir, tdim, n) -> None: filename = Path(tempdir, "mesh.xdmf") mesh = mesh_factory(tdim, n) encoding = XDMFFile.Encoding.HDF5 diff --git a/python/test/unit/la/test_matmul.py b/python/test/unit/la/test_matmul.py index 7ca43c5471b..0198a2686a3 100644 --- a/python/test/unit/la/test_matmul.py +++ b/python/test/unit/la/test_matmul.py @@ -18,7 +18,7 @@ np.complex128, ], ) -def test_matmul(dtype, mat_random, mat_gather): +def test_matmul(dtype, mat_random, mat_gather) -> None: # Create two random square MatrixCSR A = mat_random(0, 0, 12345, dtype) B = mat_random(0, 0, 54321, dtype) @@ -50,7 +50,7 @@ def test_matmul(dtype, mat_random, mat_gather): np.complex128, ], ) -def test_matmul_rect(dtype, mat_random, mat_gather): +def test_matmul_rect(dtype, mat_random, mat_gather) -> None: # Create two random rectangular MatrixCSR A = mat_random(0, 1, 12345, dtype) B = mat_random(1, 0, 54321, dtype) @@ -82,7 +82,7 @@ def test_matmul_rect(dtype, mat_random, mat_gather): np.complex128, ], ) -def test_matmul_zeros(dtype, mat_random, mat_gather): +def test_matmul_zeros(dtype, mat_random, mat_gather) -> None: A = mat_random(0, 0, 123, dtype) # Make first two entries in row zero of A (+1, +1). A.data[0] = 1.0 @@ -117,7 +117,7 @@ def test_matmul_zeros(dtype, mat_random, mat_gather): assert np.allclose(Cs.todense(), C.todense()) -def test_bad_shape(mat_random): +def test_bad_shape(mat_random) -> None: # Test matmul of incompatible matrices (should raise an error) A = mat_random(0, 1, 12345, np.float64) B = mat_random(0, 2, 54321, np.float64) diff --git a/python/test/unit/la/test_matrix_csr.py b/python/test/unit/la/test_matrix_csr.py index 81e263d337f..53d3d6105a1 100644 --- a/python/test/unit/la/test_matrix_csr.py +++ b/python/test/unit/la/test_matrix_csr.py @@ -31,7 +31,7 @@ def create_test_sparsity(n, bs): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_add(dtype): +def test_add(dtype) -> None: # Regular CSR Matrix 6x6 with bs=1 sp = create_test_sparsity(6, 1) mat1 = matrix_csr(sp, dtype=dtype) @@ -75,7 +75,7 @@ def test_add(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_set(dtype): +def test_set(dtype) -> None: mpi_size = MPI.COMM_WORLD.size # Regular CSR Matrix 6x6 with bs=1 sp = create_test_sparsity(6, 1) @@ -93,7 +93,7 @@ def test_set(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_set_blocked(dtype): +def test_set_blocked(dtype) -> None: mpi_size = MPI.COMM_WORLD.size # Blocked CSR Matrix 3x3 with bs=2 sp = create_test_sparsity(3, 2) @@ -106,7 +106,7 @@ def test_set_blocked(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_distributed_csr(dtype): +def test_distributed_csr(dtype) -> None: size = MPI.COMM_WORLD.size rank = MPI.COMM_WORLD.rank if size == 1: @@ -175,7 +175,7 @@ def test_set_block_matrix(dtype): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_set_diagonal_distributed(dtype): +def test_set_diagonal_distributed(dtype) -> None: mesh_dtype = np.real(dtype(0)).dtype ghost_mode = GhostMode.shared_facet mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, ghost_mode=ghost_mode, dtype=mesh_dtype) @@ -256,7 +256,7 @@ def test_set_diagonal_distributed(dtype): pytest.param(np.complex128, marks=pytest.mark.xfail_win32_complex), ], ) -def test_set_diagonal_per_row(dtype): +def test_set_diagonal_per_row(dtype) -> None: """Test setting a different diagonal value for each row.""" mesh = create_unit_square(MPI.COMM_WORLD, 6, 5, dtype=np.real(dtype(0)).dtype) V = fem.functionspace(mesh, ("Lagrange", 1)) @@ -294,7 +294,7 @@ def test_set_diagonal_per_row(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_bad_entry(dtype): +def test_bad_entry(dtype) -> None: sp = create_test_sparsity(6, 1) mat1 = matrix_csr(sp, dtype=dtype) @@ -314,7 +314,7 @@ def test_bad_entry(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_eliminate_zeros_tolerance(dtype): +def test_eliminate_zeros_tolerance(dtype) -> None: """Entries are removed from storage iff |value| <= tol (i.e. kept iff strictly greater than tol), and storage is compacted accordingly. """ @@ -357,7 +357,7 @@ def test_eliminate_zeros_tolerance(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_eliminate_zeros_default_tolerance(dtype): +def test_eliminate_zeros_default_tolerance(dtype) -> None: """With no tolerance supplied, only exact structural zeros are removed; small-but-nonzero entries must survive. @@ -392,7 +392,7 @@ def test_eliminate_zeros_default_tolerance(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_eliminate_zeros_no_change_when_nothing_within_tolerance(dtype): +def test_eliminate_zeros_no_change_when_nothing_within_tolerance(dtype) -> None: """eliminate_zeros must be a no-op (and not corrupt data) when no entries fall within the given tolerance. """ @@ -410,7 +410,7 @@ def test_eliminate_zeros_no_change_when_nothing_within_tolerance(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_eliminate_zeros_blocked_partial(dtype): +def test_eliminate_zeros_blocked_partial(dtype) -> None: """A block with any entry above tolerance must be kept in full, even though some of its other entries are within tolerance. """ @@ -429,7 +429,7 @@ def test_eliminate_zeros_blocked_partial(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_eliminate_zeros_blocked_whole_block(dtype): +def test_eliminate_zeros_blocked_whole_block(dtype) -> None: """A block is only dropped from storage when *every* one of its bs0*bs1 entries is within tolerance; a block with even one entry above tolerance is kept in full, byte-for-byte. @@ -462,7 +462,7 @@ def test_eliminate_zeros_blocked_whole_block(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) -def test_eliminate_zeros_finalizes(dtype): +def test_eliminate_zeros_finalizes(dtype) -> None: """eliminate_zeros() can shrink the sparsity, which invalidates the precomputed ghost-row communication pattern. Once called, further modification of the matrix must be rejected rather than silently diff --git a/python/test/unit/la/test_matrix_vector.py b/python/test/unit/la/test_matrix_vector.py index 06344b65b57..7a310caa034 100644 --- a/python/test/unit/la/test_matrix_vector.py +++ b/python/test/unit/la/test_matrix_vector.py @@ -53,7 +53,7 @@ def test_create_matrix_csr(): np.complex128, ], ) -def test_matvec(bs, dtype, mat_random, mat_gather): +def test_matvec(bs, dtype, mat_random, mat_gather) -> None: A = mat_random(0, 0, 12345, dtype, bs) Ascipy = mat_gather(A) imap = A.index_map(0) @@ -83,7 +83,7 @@ def test_matvec(bs, dtype, mat_random, mat_gather): np.complex128, ], ) -def test_matvec_transpose(bs, dtype, mat_random, mat_gather): +def test_matvec_transpose(bs, dtype, mat_random, mat_gather) -> None: # Create a random square MatrixCSR A = mat_random(0, 0, 54321, dtype, bs) @@ -117,7 +117,7 @@ def test_matvec_transpose(bs, dtype, mat_random, mat_gather): np.int64, ], ) -def test_create_vector(dtype): +def test_create_vector(dtype) -> None: """Test creation of a distributed vector.""" mesh = create_unit_square(MPI.COMM_WORLD, 5, 5) im = mesh.topology.index_map(0) @@ -161,7 +161,7 @@ def xfail_norm_of_integral_type_vector(dtype): ), ], ) -def test_vector_norm(dtype, norm_type): +def test_vector_norm(dtype, norm_type) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5) im = mesh.topology.index_map(0) x = la.vector(im, dtype=dtype) diff --git a/python/test/unit/la/test_nullspace.py b/python/test/unit/la/test_nullspace.py index ea49f6515da..b69e97b96ba 100644 --- a/python/test/unit/la/test_nullspace.py +++ b/python/test/unit/la/test_nullspace.py @@ -57,7 +57,7 @@ def build_elastic_nullspace(V, dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("degree", [1, 2]) -def test_nullspace_orthogonal(gdim, degree, dtype): +def test_nullspace_orthogonal(gdim, degree, dtype) -> None: """Test null spaces orthogonalisation.""" xtype = dtype(0).real.dtype if gdim == 2: @@ -83,7 +83,7 @@ def test_nullspace_orthogonal(gdim, degree, dtype): ) @pytest.mark.parametrize("gdim", [2, 3]) @pytest.mark.parametrize("degree", [1, 2]) -def test_nullspace_check(gdim, degree, dtype): +def test_nullspace_check(gdim, degree, dtype) -> None: """Test that elasticity nullspace is actually a nullspace.""" # TODO: Once we support SpMV, run on MPI.COMM_WORLD comm = MPI.COMM_SELF diff --git a/python/test/unit/la/test_petsc_matrix.py b/python/test/unit/la/test_petsc_matrix.py index 741507d4b21..74864d70954 100644 --- a/python/test/unit/la/test_petsc_matrix.py +++ b/python/test/unit/la/test_petsc_matrix.py @@ -16,7 +16,7 @@ @pytest.mark.petsc4py @pytest.mark.parametrize("mat_type", ["aij", "is"]) -def test_shared_index_map_shares_lgmap(mat_type): +def test_shared_index_map_shares_lgmap(mat_type) -> None: """One index map for both dimensions gives one local-to-global map. ``la::petsc::create_matrix`` attaches the row mapping to both diff --git a/python/test/unit/la/test_sparsity_pattern.py b/python/test/unit/la/test_sparsity_pattern.py index f13d125a58f..c7422614f05 100644 --- a/python/test/unit/la/test_sparsity_pattern.py +++ b/python/test/unit/la/test_sparsity_pattern.py @@ -16,7 +16,7 @@ from dolfinx.mesh import create_unit_square, exterior_facet_indices -def test_add_diagonal(): +def test_add_diagonal() -> None: """Test adding entries to diagonal of sparsity pattern.""" mesh = create_unit_square(MPI.COMM_WORLD, 10, 10) gdim = mesh.geometry.dim @@ -34,7 +34,7 @@ def test_add_diagonal(): assert len(blocks) == pattern.num_nonzeros -def test_blocked_pattern_with_empty_blocks(): +def test_blocked_pattern_with_empty_blocks() -> None: """Test creation of a blocked pattern with structural zero blocks.""" # COMM_SELF: the block structure under test is process-local and # involves no cross-rank communication, so the test runs unmodified @@ -51,7 +51,7 @@ def test_blocked_pattern_with_empty_blocks(): assert blocked_pattern.num_nonzeros == 0 -def test_index_map_column_growth(): +def test_index_map_column_growth() -> None: """Finalizing can add column ghosts without changing the input maps. Rank 1 assembles an entry on a row it does not own, at a column the diff --git a/python/test/unit/la/test_superlu_dist.py b/python/test/unit/la/test_superlu_dist.py index 9b4d6326081..111dd36c8be 100644 --- a/python/test/unit/la/test_superlu_dist.py +++ b/python/test/unit/la/test_superlu_dist.py @@ -37,7 +37,7 @@ ], ) @pytest.mark.skipif(not dolfinx.has_superlu_dist, reason="No SuperLU_DIST") -def test_superlu_solver(dtype): +def test_superlu_solver(dtype) -> None: """Manufactured Poisson and screened problem with exact solution u = x[1]**3. Test includes various checks that SuperLU_DIST Factor option works correctly @@ -148,7 +148,7 @@ def solve_and_check(solver, b): ], ) @pytest.mark.skipif(not dolfinx.has_superlu_dist, reason="No SuperLU_DIST") -def test_superlu_solver_blocked(dtype): +def test_superlu_solver_blocked(dtype) -> None: """Vector Poisson problem on a vector Lagrange space (block size 2).""" from dolfinx.la.superlu_dist import superlu_dist_matrix, superlu_dist_solver @@ -202,7 +202,7 @@ def u_ex(x): @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex128]) @pytest.mark.skipif(not dolfinx.has_superlu_dist, reason="No SuperLU_DIST") @pytest.mark.skipif(MPI.COMM_WORLD.size > 1, reason="Hand-built single-rank matrix") -def test_superlu_solver_asymmetric_blocks(dtype): +def test_superlu_solver_asymmetric_blocks(dtype) -> None: """Hand-built MatrixCSR with bs[0] = 2 and bs[1] = 3 and final size 6 x 6.""" from dolfinx.la.superlu_dist import superlu_dist_matrix, superlu_dist_solver diff --git a/python/test/unit/la/test_transpose.py b/python/test/unit/la/test_transpose.py index d3e04bb1a19..9abab31ffe2 100644 --- a/python/test/unit/la/test_transpose.py +++ b/python/test/unit/la/test_transpose.py @@ -18,7 +18,7 @@ np.complex128, ], ) -def test_transpose_square(dtype, mat_random, mat_gather): +def test_transpose_square(dtype, mat_random, mat_gather) -> None: # Create random square MatrixCSR A = mat_random(0, 0, 12345, dtype) @@ -46,7 +46,7 @@ def test_transpose_square(dtype, mat_random, mat_gather): np.complex128, ], ) -def test_transpose_block(dtype, bs, mat_random, mat_gather): +def test_transpose_block(dtype, bs, mat_random, mat_gather) -> None: # Create random rectangular MatrixCSR with various block sizes A = mat_random(0, 1, 12345, dtype, bs) Ascipy = mat_gather(A) diff --git a/python/test/unit/la/test_vector_scatter.py b/python/test/unit/la/test_vector_scatter.py index f49ed17bb38..431dcaa40d3 100644 --- a/python/test/unit/la/test_vector_scatter.py +++ b/python/test/unit/la/test_vector_scatter.py @@ -23,7 +23,7 @@ element("Lagrange", "triangle", 1, shape=(2,), dtype=default_real_type), ], ) -def test_scatter_forward(e): +def test_scatter_forward(e) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 5, 5) V = functionspace(mesh, e) u = Function(V) @@ -55,7 +55,7 @@ def test_scatter_forward(e): element("Lagrange", "triangle", 1, shape=(2,), dtype=default_real_type), ], ) -def test_scatter_reverse(e): +def test_scatter_reverse(e) -> None: comm = MPI.COMM_WORLD mesh = create_unit_square(MPI.COMM_WORLD, 5, 5) V = functionspace(mesh, e) @@ -97,7 +97,7 @@ def test_scatter_reverse(e): np.int64, ], ) -def test_vector_from_index_map_scatter_forward(dtype): +def test_vector_from_index_map_scatter_forward(dtype) -> None: comm = MPI.COMM_WORLD mesh = create_unit_square(comm, 5, 5) @@ -113,7 +113,7 @@ def test_vector_from_index_map_scatter_forward(dtype): assert np.all(vector.array == global_idxs) -def test_vector_from_scatterer(): +def test_vector_from_scatterer() -> None: """Test creating vectors that share a scatterer.""" comm = MPI.COMM_WORLD mesh = create_unit_square(comm, 5, 5) diff --git a/python/test/unit/mesh/test_cell.py b/python/test/unit/mesh/test_cell.py index a38aa9e2878..13014e0ed34 100644 --- a/python/test/unit/mesh/test_cell.py +++ b/python/test/unit/mesh/test_cell.py @@ -17,7 +17,7 @@ @pytest.mark.skip_in_parallel -def test_distance_interval(): +def test_distance_interval() -> None: mesh = create_unit_interval(MPI.COMM_SELF, 1) d = np.array([-1.0, 0.0, 0.0]) assert squared_distance(mesh, mesh.topology.dim, np.array([0]), d) == pytest.approx(1.0) diff --git a/python/test/unit/mesh/test_dual_graph.py b/python/test/unit/mesh/test_dual_graph.py index 35867119370..8152291ece2 100644 --- a/python/test/unit/mesh/test_dual_graph.py +++ b/python/test/unit/mesh/test_dual_graph.py @@ -16,7 +16,7 @@ def to_adj(cells, dtype): return adj -def test_dgrsph_1d(): +def test_dgrsph_1d() -> None: rank = MPI.COMM_WORLD.Get_rank() size = MPI.COMM_WORLD.Get_size() n0 = rank * 3 diff --git a/python/test/unit/mesh/test_face.py b/python/test/unit/mesh/test_face.py index c129317dbc3..af92530c06d 100644 --- a/python/test/unit/mesh/test_face.py +++ b/python/test/unit/mesh/test_face.py @@ -27,7 +27,7 @@ def square(): return create_unit_square(MPI.COMM_WORLD, 5, 5) -def test_normals(cube, square): +def test_normals(cube, square) -> None: """Test cell normals for a subset of facets.""" def left_side(x): diff --git a/python/test/unit/mesh/test_ghost_mesh.py b/python/test/unit/mesh/test_ghost_mesh.py index b95d188bc9d..be54bce8258 100644 --- a/python/test/unit/mesh/test_ghost_mesh.py +++ b/python/test/unit/mesh/test_ghost_mesh.py @@ -18,14 +18,14 @@ ) -def test_ghost_facet_1d(): +def test_ghost_facet_1d() -> None: N = 40 mesh = create_unit_interval(MPI.COMM_WORLD, N, ghost_mode=GhostMode.shared_facet) assert mesh.topology.index_map(0).size_global == N + 1 assert mesh.topology.index_map(1).size_global == N -def test_ghost_2d(): +def test_ghost_2d() -> None: N = 8 num_cells = N * N * 2 mesh = create_unit_square(MPI.COMM_WORLD, N, N, ghost_mode=GhostMode.shared_facet) @@ -37,7 +37,7 @@ def test_ghost_2d(): assert mesh.topology.index_map(2).size_global == num_cells -def test_ghost_3d(): +def test_ghost_3d() -> None: N = 2 num_cells = N * N * N * 6 mesh = create_unit_cube(MPI.COMM_WORLD, N, N, N, ghost_mode=GhostMode.shared_facet) diff --git a/python/test/unit/mesh/test_higher_order_mesh.py b/python/test/unit/mesh/test_higher_order_mesh.py index 41a2e574a2b..2352125eb3a 100644 --- a/python/test/unit/mesh/test_higher_order_mesh.py +++ b/python/test/unit/mesh/test_higher_order_mesh.py @@ -138,7 +138,7 @@ def coord_to_vertex(x, y, z): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", range(1, 5)) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_triangle_mesh(order, dtype): +def test_triangle_mesh(order, dtype) -> None: points = [] points += [[i / order, 0] for i in range(order + 1)] for j in range(1, order): @@ -178,7 +178,7 @@ def coord_to_vertex(x, y): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", range(1, 5)) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_tetrahedron_mesh(order, dtype): +def test_tetrahedron_mesh(order, dtype) -> None: points = [] points += [[i / order, j / order, 0] for j in range(order + 1) for i in range(order + 1 - j)] for k in range(1, order): @@ -251,7 +251,7 @@ def coord_to_vertex(x, y, z): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2, 3, 4]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_quadrilateral_mesh(order, dtype): +def test_quadrilateral_mesh(order, dtype) -> None: random.seed(13) points = [] @@ -295,7 +295,7 @@ def coord_to_vertex(x, y): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2, 3, 4]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_hexahedron_mesh(order, dtype): +def test_hexahedron_mesh(order, dtype) -> None: random.seed(13) points = [] points += [[i / order, j / order, 0] for j in range(order + 1) for i in range(order + 1)] @@ -392,7 +392,7 @@ def coord_to_vertex(x, y, z): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", range(1, 5)) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_triangle_mesh_vtk(order, dtype): +def test_triangle_mesh_vtk(order, dtype) -> None: points = [] points += [[i / order, 0] for i in range(order + 1)] for j in range(1, order): @@ -439,7 +439,7 @@ def coord_to_vertex(x, y): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", range(1, 5)) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_tetrahedron_mesh_vtk(order, dtype): +def test_tetrahedron_mesh_vtk(order, dtype) -> None: points = [] points += [[i / order, j / order, 0] for j in range(order + 1) for i in range(order + 1 - j)] for k in range(1, order): @@ -545,7 +545,7 @@ def coord_to_vertex(x, y, z): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2, 3, 4]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_quadrilateral_mesh_vtk(order, dtype): +def test_quadrilateral_mesh_vtk(order, dtype) -> None: random.seed(13) points = [] @@ -591,7 +591,7 @@ def coord_to_vertex(x, y): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2, 3, 4]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_hexahedron_mesh_vtk(order, dtype): +def test_hexahedron_mesh_vtk(order, dtype) -> None: random.seed(13) points = [] @@ -702,7 +702,7 @@ def coord_to_vertex(x, y, z): ], ) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_map_vtk_to_dolfin(vtk, dolfin, cell_type, dtype): +def test_map_vtk_to_dolfin(vtk, dolfin, cell_type, dtype) -> None: p = cell_perm_vtk(cell_type, len(vtk)) cell_p = np.array(vtk)[p] assert (cell_p == dolfin).all() @@ -715,7 +715,7 @@ def test_map_vtk_to_dolfin(vtk, dolfin, cell_type, dtype): @pytest.mark.skipif(default_real_type != np.float64, reason="float32 not supported yet") @pytest.mark.skip_in_parallel @pytest.mark.parametrize("dtype", [np.float64]) -def test_xdmf_input_tri(datadir, dtype): +def test_xdmf_input_tri(datadir, dtype) -> None: with XDMFFile( MPI.COMM_WORLD, Path(datadir, "mesh.xdmf"), "r", encoding=XDMFFile.Encoding.ASCII ) as xdmf: @@ -727,7 +727,7 @@ def test_xdmf_input_tri(datadir, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_gmsh_mixed_mesh_2d(order, dtype): +def test_gmsh_mixed_mesh_2d(order, dtype) -> None: try: import gmsh except ImportError: @@ -782,7 +782,7 @@ def test_gmsh_mixed_mesh_2d(order, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2, 3]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_gmsh_input_2d(order, dtype): +def test_gmsh_input_2d(order, dtype) -> None: try: import gmsh except ImportError: @@ -815,7 +815,7 @@ def test_gmsh_input_2d(order, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_gmsh_mixed_mesh_3d(order, dtype): +def test_gmsh_mixed_mesh_3d(order, dtype) -> None: try: import gmsh except ImportError: @@ -907,7 +907,7 @@ def test_gmsh_mixed_mesh_3d(order, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("order", [1, 2, 3]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_gmsh_tetra(order, dtype): +def test_gmsh_tetra(order, dtype) -> None: try: import gmsh except ImportError: @@ -942,7 +942,7 @@ def test_gmsh_tetra(order, dtype): @pytest.mark.skip_in_parallel @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_quadrilateral_cell_order_3(dtype): +def test_quadrilateral_cell_order_3(dtype) -> None: points = [ [0.0, 0.0], [1.0, 0.0], @@ -976,7 +976,7 @@ def test_quadrilateral_cell_order_3(dtype): @pytest.mark.parametrize("order", range(1, 11)) -def test_vtk_perm_tetrahedron(order): +def test_vtk_perm_tetrahedron(order) -> None: size = (order + 1) * (order + 2) * (order + 3) // 6 p = cell_perm_vtk(CellType.tetrahedron, size) @@ -1983,7 +1983,7 @@ def test_vtk_perm_tetrahedron(order): @pytest.mark.parametrize("order", range(1, 7)) -def test_vtk_perm_hexahedron(order): +def test_vtk_perm_hexahedron(order) -> None: size = (order + 1) ** 3 p = cell_perm_vtk(CellType.hexahedron, size) diff --git a/python/test/unit/mesh/test_manifold_point_search.py b/python/test/unit/mesh/test_manifold_point_search.py index 86de5b27abb..48097441bc4 100644 --- a/python/test/unit/mesh/test_manifold_point_search.py +++ b/python/test/unit/mesh/test_manifold_point_search.py @@ -11,7 +11,7 @@ @pytest.mark.skip_in_parallel -def test_manifold_point_search(): +def test_manifold_point_search() -> None: # Simple two-triangle surface in 3d vertices = np.array([[0.0, 0.0, 1.0], [1.0, 1.0, 1.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) cells = np.array([[0, 1, 2], [0, 1, 3]], dtype=np.int64) diff --git a/python/test/unit/mesh/test_mesh.py b/python/test/unit/mesh/test_mesh.py index 36bf366caa8..948abdd3de7 100644 --- a/python/test/unit/mesh/test_mesh.py +++ b/python/test/unit/mesh/test_mesh.py @@ -44,7 +44,7 @@ ) -def test_ufl_cargo_does_not_keep_mesh_wrapper_alive(): +def test_ufl_cargo_does_not_keep_mesh_wrapper_alive() -> None: """Test that UFL cargo does not create a reference cycle.""" msh = create_unit_square(MPI.COMM_SELF, 2, 2) domain = msh.ufl_domain() @@ -62,7 +62,7 @@ def test_ufl_cargo_does_not_keep_mesh_wrapper_alive(): assert recovered_mesh.topology.index_map(recovered_mesh.topology.dim).size_local == 8 -def test_ufl_cargo_outlives_mesh_and_domain(): +def test_ufl_cargo_outlives_mesh_and_domain() -> None: """Test that cargo attribute access works once the wrappers are gone.""" msh = create_unit_square(MPI.COMM_SELF, 2, 2) domain = msh.ufl_domain() @@ -148,7 +148,7 @@ def submesh_geometry_test(mesh, submesh, entity_map, geom_map, entity_dim): @pytest.mark.parametrize("cell_type", [_mesh.CellType.triangle, _mesh.CellType.quadrilateral]) -def test_empty_entities_to_geometry(cell_type): +def test_empty_entities_to_geometry(cell_type) -> None: """Test entities_to_geometry with empty entity list.""" mesh = _mesh.create_unit_square(MPI.COMM_WORLD, 10, 12, cell_type=cell_type) @@ -275,7 +275,7 @@ def new_comm(comm): return new_comm -def test_UFLCell(interval, square, rectangle, cube, box): +def test_UFLCell(interval, square, rectangle, cube, box) -> None: import ufl assert ufl.interval == interval.ufl_cell() @@ -285,7 +285,7 @@ def test_UFLCell(interval, square, rectangle, cube, box): assert ufl.tetrahedron == box.ufl_cell() -def test_UFLDomain(interval, square, rectangle, cube, box): +def test_UFLDomain(interval, square, rectangle, cube, box) -> None: def _check_ufl_domain(mesh): domain = mesh.ufl_domain() assert mesh.geometry.dim == domain.geometric_dimension @@ -301,7 +301,7 @@ def _check_ufl_domain(mesh): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("comm", [MPI.COMM_SELF, MPI.COMM_WORLD]) -def test_create_unit_square(comm, dtype): +def test_create_unit_square(comm, dtype) -> None: """Create mesh of unit square.""" mesh = create_unit_square(comm, 5, 7, dtype=dtype) assert mesh.topology.index_map(0).size_global == 48 @@ -313,7 +313,7 @@ def test_create_unit_square(comm, dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("comm", [MPI.COMM_SELF, MPI.COMM_WORLD]) -def test_create_unit_cube(comm, dtype): +def test_create_unit_cube(comm, dtype) -> None: """Create mesh of unit cube.""" mesh = create_unit_cube(comm, 5, 7, 9, dtype=dtype) assert mesh.topology.index_map(0).size_global == 480 @@ -325,7 +325,7 @@ def test_create_unit_cube(comm, dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("comm", [MPI.COMM_SELF, MPI.COMM_WORLD]) -def test_create_unit_square_quads(comm, dtype): +def test_create_unit_square_quads(comm, dtype) -> None: mesh = create_unit_square(comm, 5, 7, CellType.quadrilateral, dtype=dtype) assert mesh.topology.index_map(0).size_global == 48 assert mesh.topology.index_map(2).size_global == 35 @@ -336,7 +336,7 @@ def test_create_unit_square_quads(comm, dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) @pytest.mark.parametrize("comm", [MPI.COMM_SELF, MPI.COMM_WORLD]) -def test_create_unit_square_hex(comm, dtype): +def test_create_unit_square_hex(comm, dtype) -> None: mesh = create_unit_cube(comm, 5, 7, 9, CellType.hexahedron, dtype=dtype) assert mesh.topology.index_map(0).size_global == 480 assert mesh.topology.index_map(3).size_global == 315 @@ -345,7 +345,7 @@ def test_create_unit_square_hex(comm, dtype): assert mesh.geometry.x.dtype == dtype -def test_create_box_prism(): +def test_create_box_prism() -> None: mesh = create_box( MPI.COMM_WORLD, [[0.0, 0.0, 0.0], [1.0, 1.0, 1.0]], @@ -359,7 +359,7 @@ def test_create_box_prism(): @pytest.mark.parametrize("gdim", [1, 2, 3]) -def test_create_interval_gdim(gdim): +def test_create_interval_gdim(gdim) -> None: """Interval mesh embedded in gdim-dimensional space has correct tdim and gdim.""" mesh = create_interval(MPI.COMM_WORLD, 6, [0.0, 1.0], gdim=gdim) assert mesh.topology.dim == 1 @@ -371,7 +371,7 @@ def test_create_interval_gdim(gdim): @pytest.mark.parametrize("cell_type", [CellType.triangle, CellType.quadrilateral]) @pytest.mark.parametrize("gdim", [2, 3]) -def test_create_rectangle_gdim(gdim, cell_type): +def test_create_rectangle_gdim(gdim, cell_type) -> None: """Rectangle mesh embedded in gdim-dimensional space has correct tdim and gdim.""" mesh = create_rectangle(MPI.COMM_WORLD, [[0.0, 0.0], [1.0, 1.0]], [4, 4], cell_type, gdim=gdim) assert mesh.topology.dim == 2 @@ -382,20 +382,20 @@ def test_create_rectangle_gdim(gdim, cell_type): @pytest.mark.skip_in_parallel -def test_get_coordinates(): +def test_get_coordinates() -> None: """Get coordinates of vertices.""" mesh = create_unit_square(MPI.COMM_WORLD, 5, 5) assert len(mesh.geometry.x) == 36 @pytest.mark.skip_in_parallel -def test_cell_h(c0, c1, c5): +def test_cell_h(c0, c1, c5) -> None: for c in [c0, c1, c5]: c[0].topology.create_connectivity(c[1], c[1]) assert c[0].h(c[1], np.array([c[2]])) -def test_cell_h_prism(): +def test_cell_h_prism() -> None: N = 3 mesh = create_unit_cube(MPI.COMM_WORLD, N, N, N, cell_type=CellType.prism) tdim = mesh.topology.dim @@ -407,7 +407,7 @@ def test_cell_h_prism(): @pytest.mark.parametrize("ct", [CellType.hexahedron, CellType.tetrahedron]) -def test_facet_h(ct): +def test_facet_h(ct) -> None: N = 3 mesh = create_unit_cube(MPI.COMM_WORLD, N, N, N, ct) left_facets = locate_entities_boundary( @@ -432,7 +432,7 @@ def dirname(request): (mesh_3d, math.sqrt(2.0), math.sqrt(2.0)), ], ) -def test_hmin_hmax(_mesh, dtype, hmin, hmax): +def test_hmin_hmax(_mesh, dtype, hmin, hmax) -> None: mesh = _mesh(dtype) tdim = mesh.topology.dim mesh.topology.create_connectivity(tdim, tdim) @@ -504,7 +504,7 @@ def xtest_mesh_topology_lifetime(): @pytest.mark.skip_in_parallel -def test_small_mesh(): +def test_small_mesh() -> None: mesh3d = create_unit_cube(MPI.COMM_WORLD, 1, 1, 1) gdim = mesh3d.geometry.dim assert mesh3d.topology.index_map(gdim).size_global == 6 @@ -518,7 +518,7 @@ def test_small_mesh(): # assert mesh1d.topology.index_map(gdim).size_global == 2 -def test_unit_hex_mesh_assemble(): +def test_unit_hex_mesh_assemble() -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 6, 7, 5, CellType.hexahedron) vol = assemble_scalar(form(1 * ufl.dx(mesh))) vol = mesh.comm.allreduce(vol, MPI.SUM) @@ -546,7 +546,7 @@ def boundary_2(x): @pytest.mark.parametrize("marker", [lambda x: x[0] >= 0.5, lambda x: x[0] >= -1]) @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) @pytest.mark.parametrize("simplex", [True, False]) -def test_submesh_full(d, n, codim, marker, ghost_mode, simplex): +def test_submesh_full(d, n, codim, marker, ghost_mode, simplex) -> None: if d == 1: mesh = create_unit_interval(MPI.COMM_WORLD, n, ghost_mode=ghost_mode) elif d == 2: @@ -568,7 +568,7 @@ def test_submesh_full(d, n, codim, marker, ghost_mode, simplex): @pytest.mark.parametrize("n", [3, 6]) @pytest.mark.parametrize("boundary", [boundary_0, boundary_1, boundary_2]) @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) -def test_submesh_boundary(d, n, boundary, ghost_mode): +def test_submesh_boundary(d, n, boundary, ghost_mode) -> None: if d == 1: mesh = create_unit_interval(MPI.COMM_WORLD, n, ghost_mode=ghost_mode) elif d == 2: @@ -583,7 +583,7 @@ def test_submesh_boundary(d, n, boundary, ghost_mode): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_empty_rank_mesh(dtype): +def test_empty_rank_mesh(dtype) -> None: """Construction of mesh where some ranks are empty.""" comm = MPI.COMM_WORLD cell_type = CellType.triangle @@ -657,7 +657,7 @@ def partitioner(comm, nparts, dual_graph, cell_weights, edge_weights, ghosting): mesh.topology.create_entity_permutations(tdim) -def test_original_index(): +def test_original_index() -> None: nx = 7 mesh = create_unit_cube(MPI.COMM_WORLD, nx, nx, nx, ghost_mode=GhostMode.none) s = sum(mesh.topology.original_cell_index) @@ -666,7 +666,7 @@ def test_original_index(): @pytest.mark.skip_in_parallel -def test_create_mesh_cell_reordering(): +def test_create_mesh_cell_reordering() -> None: """Test a Python callback for cell reordering.""" cells = np.array([[0, 1, 2], [1, 3, 2]], dtype=np.int64) x = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) @@ -683,7 +683,7 @@ def reorder(dual_graph): @pytest.mark.skip_in_parallel -def test_create_mesh_cell_reordering_exception(): +def test_create_mesh_cell_reordering_exception() -> None: """Test that an exception from a cell reordering callback keeps its type.""" cells = np.array([[0, 1, 2], [1, 3, 2]], dtype=np.int64) x = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) @@ -697,7 +697,7 @@ def reorder(dual_graph): @pytest.mark.skip_in_parallel -def test_create_mesh_unreferenced_nodes(): +def test_create_mesh_unreferenced_nodes() -> None: """Nodes that no cell references are dropped from the geometry.""" cells = np.array([[0, 1, 2], [1, 4, 2]], dtype=np.int64) # Nodes 3 and 5 are not referenced by any cell @@ -721,7 +721,7 @@ def test_create_mesh_unreferenced_nodes(): @pytest.mark.skipif( not dolfinx.common.has_debug, reason="Out-of-range node index check is debug-only" ) -def test_create_mesh_node_index_out_of_range(): +def test_create_mesh_node_index_out_of_range() -> None: """A cell node index beyond the end of the node array is rejected.""" cells = np.array([[0, 1, 7]], dtype=np.int64) x = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]], dtype=default_real_type) @@ -744,7 +744,7 @@ def test_topology_connectivity_dimension_types(): msh.topology.connectivity(2, (0, 0)) -def test_wrappers_compare_equal(): +def test_wrappers_compare_equal() -> None: """Wrappers built around the same C++ object compare equal.""" msh = create_unit_square(MPI.COMM_WORLD, 3, 3) msh.topology.create_connectivity(2, 0) @@ -767,7 +767,7 @@ def test_wrappers_compare_equal(): assert dof_layout0 == dof_layout1 -def test_create_mesh_default_cell_reordering(): +def test_create_mesh_default_cell_reordering() -> None: """Test default reverse Cuthill-McKee cell reordering.""" cells = np.array([[0, 1, 2], [1, 3, 2]], dtype=np.int64) x = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) @@ -782,7 +782,7 @@ def test_create_mesh_default_cell_reordering(): @pytest.mark.skip_in_parallel -def test_create_mesh_sfc_reordering(): +def test_create_mesh_sfc_reordering() -> None: """Test a built-in space-filling-curve cell reordering.""" cells = np.array([[1, 3, 2], [0, 1, 2]], dtype=np.int64) x = np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) @@ -814,7 +814,7 @@ def compute_num_boundary_facets(mesh): @pytest.mark.parametrize("d", [2, 3]) @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_boundary_facets(n, d, ghost_mode, dtype): +def test_boundary_facets(n, d, ghost_mode, dtype) -> None: """Test that the correct number of boundary facets are computed.""" if d == 2: mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode, dtype=dtype) @@ -860,7 +860,7 @@ def test_submesh_codim_0_boundary_facets(n, d, ghost_mode, dtype): @pytest.mark.parametrize("n", [2, 5]) @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_submesh_codim_1_boundary_facets(n, ghost_mode, dtype): +def test_submesh_codim_1_boundary_facets(n, ghost_mode, dtype) -> None: """Test that the correct number of boundary facets are computed for a submesh of codim 1. """ @@ -950,7 +950,7 @@ def test_mesh_single_process_distribution(partitioner): assert adj.links(i).size == 2 -def test_create_submesh_empty_on_some_ranks(): +def test_create_submesh_empty_on_some_ranks() -> None: """create_submesh must not deadlock when some ranks have zero entities.""" mesh = create_unit_square(MPI.COMM_WORLD, 8, 8) tdim = mesh.topology.dim @@ -1002,7 +1002,7 @@ def marker2(x): @pytest.mark.parametrize("gdim", [1, 2, 3]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_point_mesh(gdim, dtype): +def test_point_mesh(gdim, dtype) -> None: rng = np.random.default_rng(12) num_points = 10 x = rng.random((num_points, gdim), dtype=dtype) @@ -1023,7 +1023,7 @@ def test_point_mesh(gdim, dtype): CellType.hexahedron, ], ) -def test_cell_permutation_info_matches_entity_permutations(cell_type): +def test_cell_permutation_info_matches_entity_permutations(cell_type) -> None: """The packed cell permutation info is the per-dimension permutations. ``get_cell_permutation_info`` packs three bits per face followed by @@ -1067,7 +1067,7 @@ def test_cell_permutation_info_matches_entity_permutations(cell_type): assert faces.any() -def test_entity_permutations_are_computed_per_dimension(): +def test_entity_permutations_are_computed_per_dimension() -> None: """Computing one dimension must not compute any other.""" msh = create_unit_cube(MPI.COMM_WORLD, 2, 2, 2) topology = msh.topology @@ -1082,7 +1082,7 @@ def test_entity_permutations_are_computed_per_dimension(): @pytest.mark.parametrize("degree", [1, 2, 3]) -def test_facet_assembly_computes_only_facet_permutations(degree): +def test_facet_assembly_computes_only_facet_permutations(degree) -> None: """A form pays only for the entities it integrates over. An interior facet form needs permutations (it reads @@ -1113,7 +1113,7 @@ def test_facet_assembly_computes_only_facet_permutations(degree): msh.topology.get_cell_permutation_info() -def test_cell_assembly_computes_only_cell_permutations(): +def test_cell_assembly_computes_only_cell_permutations() -> None: """Dof transformations need the packed cell info, but no sub-entities. The packed cell info is no longer computed as a side effect of, or diff --git a/python/test/unit/mesh/test_mesh_partitioners.py b/python/test/unit/mesh/test_mesh_partitioners.py index e70b3520e3c..1436f98eed6 100644 --- a/python/test/unit/mesh/test_mesh_partitioners.py +++ b/python/test/unit/mesh/test_mesh_partitioners.py @@ -77,7 +77,7 @@ @pytest.mark.parametrize("gpart", partitioners) @pytest.mark.parametrize("Nx", [5, 10]) @pytest.mark.parametrize("cell_type", [CellType.tetrahedron, CellType.hexahedron, CellType.prism]) -def test_partition_box_mesh(gpart, Nx, cell_type): +def test_partition_box_mesh(gpart, Nx, cell_type) -> None: mesh = create_box( MPI.COMM_WORLD, [np.array([0, 0, 0]), np.array([1, 1, 1])], @@ -148,7 +148,7 @@ def partitioner(*args): assert np.all(cell_midpoints[:, 0] <= mpi_comm.rank + 1) -def test_asymmetric_partitioner(): +def test_asymmetric_partitioner() -> None: mpi_comm = MPI.COMM_WORLD n = mpi_comm.Get_size() r = mpi_comm.Get_rank() diff --git a/python/test/unit/mesh/test_meshtags.py b/python/test/unit/mesh/test_meshtags.py index c20647abf39..78b20d26268 100644 --- a/python/test/unit/mesh/test_meshtags.py +++ b/python/test/unit/mesh/test_meshtags.py @@ -26,7 +26,7 @@ @pytest.mark.parametrize("cell_type", celltypes_3D) -def test_create(cell_type): +def test_create(cell_type) -> None: comm = MPI.COMM_WORLD mesh = create_unit_cube(comm, 6, 6, 6, cell_type) @@ -44,7 +44,7 @@ def test_create(cell_type): assert mt.name == "my-name" -def test_ufl_id(): +def test_ufl_id() -> None: """Test that UFL can process MeshTags (tests ufl_id attribute).""" comm = MPI.COMM_WORLD msh = create_unit_cube(comm, 6, 6, 6) diff --git a/python/test/unit/mesh/test_mixed_topology.py b/python/test/unit/mesh/test_mixed_topology.py index 2f12a95287f..96d576ae378 100644 --- a/python/test/unit/mesh/test_mixed_topology.py +++ b/python/test/unit/mesh/test_mixed_topology.py @@ -101,7 +101,7 @@ def test_mixed_topology_mesh(dtype): set_log_level(LogLevel.WARNING) -def test_mixed_topology_mesh_3d(): +def test_mixed_topology_mesh_3d() -> None: # Mesh = 2 tets, 1 prism, 1 hex, joined. cells = [ np.array([0, 1, 2, 3, 1, 2, 3, 4], dtype=np.int64), @@ -293,7 +293,7 @@ def test_parallel_mixed_mesh(dtype): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) -def test_create_entities(dtype): +def test_create_entities(dtype) -> None: mesh = create_unit_cube( MPI.COMM_WORLD, 2, 2, 2, CellType.prism, ghost_mode=GhostMode.none, dtype=dtype ) @@ -408,7 +408,7 @@ def front(x): assert MPI.Comm.allreduce(comm, len(facets), MPI.SUM) == 0 -def test_mixed_cell_pairs(mixed_topology_mesh): +def test_mixed_cell_pairs(mixed_topology_mesh) -> None: mesh = Mesh(mixed_topology_mesh, None) mesh.topology.create_entities(2, dolfinx.hardware_concurrency()) mesh.topology.create_connectivity(2, 3) diff --git a/python/test/unit/refinement/test_refinement.py b/python/test/unit/refinement/test_refinement.py index 49fa2e68fcd..79f047020ae 100644 --- a/python/test/unit/refinement/test_refinement.py +++ b/python/test/unit/refinement/test_refinement.py @@ -30,7 +30,7 @@ ) -def test_refine_create_unit_square(): +def test_refine_create_unit_square() -> None: """Refine mesh of unit square.""" mesh = create_unit_square(MPI.COMM_WORLD, 5, 7, ghost_mode=GhostMode.none) mesh.topology.create_entities(1) @@ -43,7 +43,7 @@ def test_refine_create_unit_square(): @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) -def test_refine_create_unit_cube(ghost_mode): +def test_refine_create_unit_cube(ghost_mode) -> None: """Refine mesh of unit cube.""" mesh = create_unit_cube(MPI.COMM_WORLD, 5, 7, 9, ghost_mode=ghost_mode) mesh.topology.create_entities(1) @@ -55,7 +55,7 @@ def test_refine_create_unit_cube(ghost_mode): assert Q -def test_refine_create_form(): +def test_refine_create_form() -> None: """Check that forms can be assembled on refined mesh.""" mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3) mesh.topology.create_entities(1) @@ -69,7 +69,7 @@ def test_refine_create_form(): assemble_matrix(a) -def test_sub_refine(): +def test_sub_refine() -> None: """Test that refinement of a subset of edges works.""" msh = create_unit_square( MPI.COMM_WORLD, 3, 4, diagonal=DiagonalType.left, ghost_mode=GhostMode.none @@ -87,7 +87,7 @@ def left_corner_edge(x, tol=1e-7): assert msh.topology.index_map(2).size_global + 3 == msh1.topology.index_map(2).size_global -def test_refine_from_cells(): +def test_refine_from_cells() -> None: """Check user interface for using local cells to define edges.""" Nx, Ny = 8, 3 assert Nx % 2 == 0 @@ -125,7 +125,7 @@ def left_side(x, tol=1e-16): ), ], ) -def test_refine_facet_meshtag(tdim, refine_plaza_wrapper): +def test_refine_facet_meshtag(tdim, refine_plaza_wrapper) -> None: if tdim == 3: msh = create_unit_cube( MPI.COMM_WORLD, 2, 3, 5, CellType.tetrahedron, ghost_mode=GhostMode.none @@ -184,7 +184,7 @@ def test_refine_facet_meshtag(tdim, refine_plaza_wrapper): ), ], ) -def test_refine_cell_meshtag(tdim, refine_plaza_wrapper): +def test_refine_cell_meshtag(tdim, refine_plaza_wrapper) -> None: if tdim == 3: msh = create_unit_cube( MPI.COMM_WORLD, 2, 3, 5, CellType.tetrahedron, ghost_mode=GhostMode.none @@ -216,7 +216,7 @@ def test_refine_ufl_cargo(): @pytest.mark.parametrize("tdim", [1, 2, 3]) @pytest.mark.parametrize("ghost_mode", [GhostMode.none, GhostMode.shared_facet]) -def test_identity_partitioner(tdim, ghost_mode): +def test_identity_partitioner(tdim, ghost_mode) -> None: n = 2 if tdim == 1: mesh = create_unit_interval(MPI.COMM_WORLD, n) diff --git a/python/test/unit/refinement/test_uniform.py b/python/test/unit/refinement/test_uniform.py index dfb3766e084..55f1bd9b47d 100644 --- a/python/test/unit/refinement/test_uniform.py +++ b/python/test/unit/refinement/test_uniform.py @@ -7,7 +7,7 @@ @pytest.mark.parametrize("ctype", [CellType.hexahedron, CellType.tetrahedron, CellType.prism]) -def test_uniform_refinement_3d(ctype): +def test_uniform_refinement_3d(ctype) -> None: mesh = create_unit_cube(MPI.COMM_WORLD, 3, 2, 1, cell_type=ctype) ncells0 = mesh.topology.index_map(3).size_local @@ -21,7 +21,7 @@ def test_uniform_refinement_3d(ctype): @pytest.mark.parametrize("ctype", [CellType.triangle, CellType.quadrilateral]) -def test_uniform_refinement_2d(ctype): +def test_uniform_refinement_2d(ctype) -> None: mesh = create_unit_square(MPI.COMM_WORLD, 12, 11, cell_type=ctype) ncells0 = mesh.topology.index_map(2).size_local @@ -33,7 +33,7 @@ def test_uniform_refinement_2d(ctype): assert mesh.comm.allreduce(ncells0) * 4 == mesh.comm.allreduce(ncells1) -def test_uniform_refine_mixed_mesh(mixed_topology_mesh): +def test_uniform_refine_mixed_mesh(mixed_topology_mesh) -> None: mesh = Mesh(mixed_topology_mesh, None) ct = mesh.topology.entity_types[3]