diff --git a/python/test/unit/fem/test_assembler.py b/python/test/unit/fem/test_assembler.py index 600fab8bc2a..d8a9d2138b4 100644 --- a/python/test/unit/fem/test_assembler.py +++ b/python/test/unit/fem/test_assembler.py @@ -594,7 +594,6 @@ def nested_solve(): ksp_p.setType("preonly") def monitor(ksp, its, rnorm): - # print("Num it, rnorm:", its, rnorm) pass ksp.setTolerances(rtol=1.0e-8, max_it=50) @@ -603,8 +602,11 @@ def monitor(ksp, its, rnorm): x = b.copy() ksp.solve(b, x) assert ksp.getConvergedReason() > 0 - ksp.destroy() - return b.norm(), x.norm(), nest_matrix_norm(A), nest_matrix_norm(P) + norms = (b.norm(), x.norm(), nest_matrix_norm(A), nest_matrix_norm(P)) + pc.destroy(), ksp.destroy() + A.destroy() + b.destroy(), x.destroy() + return norms def blocked_solve(): """Blocked (monolithic) solver""" @@ -800,11 +802,10 @@ def bc(V): @pytest.mark.parametrize("mode", [GhostMode.none, GhostMode.shared_facet]) @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) def test_basic_assembly_constant(mode, dtype): - """Tests assembly with Constant + """Tests assembly with Constant. The following test should be sensitive to order of flattening the matrix-valued constant. - """ xtype = dtype(0).real.dtype mesh = create_unit_square(MPI.COMM_WORLD, 5, 5, ghost_mode=mode, dtype=xtype) @@ -867,7 +868,7 @@ def mat_insert(rows, cols, vals): def test_pack_coefficients(): - """Test packing of form coefficients ahead of main assembly call""" + """Test packing of form coefficients ahead of main assembly call.""" mesh = create_unit_square(MPI.COMM_WORLD, 12, 15) V = functionspace(mesh, ("Lagrange", 1)) diff --git a/python/test/unit/fem/test_nonlinear_assembler.py b/python/test/unit/fem/test_nonlinear_assembler.py index 3cdb70a6ac4..f4917aa69e0 100644 --- a/python/test/unit/fem/test_nonlinear_assembler.py +++ b/python/test/unit/fem/test_nonlinear_assembler.py @@ -564,9 +564,9 @@ def nested(): Jnorm = nest_matrix_norm(Jmat) Fnorm = Fvec.norm() xnorm = x.norm() - Jmat.destroy() - Fvec.destroy() + Jmat.destroy(), Fvec.destroy() x.destroy() + Pmat.destroy() return Jnorm, Fnorm, xnorm def monolithic(): diff --git a/python/test/unit/la/test_nullspace.py b/python/test/unit/la/test_nullspace.py index 3e44dea5f7b..282cb22feb1 100644 --- a/python/test/unit/la/test_nullspace.py +++ b/python/test/unit/la/test_nullspace.py @@ -103,6 +103,8 @@ def test_nullspace_orthogonal(mesh, degree): assert not la.is_orthonormal(nullspace, eps=1.0e-4) la.orthonormalize(nullspace) assert la.is_orthonormal(nullspace, eps=1.0e-3) + for x in nullspace: + x.destroy() @pytest.mark.parametrize("mesh", [ @@ -144,3 +146,5 @@ def sigma(w, gdim): la.orthonormalize(nullspace) ns = PETSc.NullSpace().create(vectors=nullspace) assert not ns.test(A) + for x in nullspace: + x.destroy()