diff --git a/tests/firedrake/conftest.py b/tests/firedrake/conftest.py index 80090a753c..f42b911b91 100644 --- a/tests/firedrake/conftest.py +++ b/tests/firedrake/conftest.py @@ -122,9 +122,13 @@ def pytest_collection_modifyitems(session, config, items): @pytest.fixture(scope="module", autouse=True) def check_empty_tape(request): """Check that the tape is empty at the end of each module""" - from pyadjoint.tape import get_working_tape + from pyadjoint.tape import annotate_tape, get_working_tape def fin(): + # make sure taping is switched off + assert not annotate_tape() + + # make sure the tape is empty tape = get_working_tape() if tape is not None: assert len(tape.get_blocks()) == 0 diff --git a/tests/firedrake/demos/test_demos_run.py b/tests/firedrake/demos/test_demos_run.py index 9d6fdb9a3f..e08be26275 100644 --- a/tests/firedrake/demos/test_demos_run.py +++ b/tests/firedrake/demos/test_demos_run.py @@ -152,6 +152,7 @@ def test_serial_demo(demo, env, monkeypatch, tmpdir): _exec_file(py_file) if "adjoint" in demo.requirements: + pyadjoint.pause_annotation() pyadjoint.get_working_tape().clear_tape() @@ -164,4 +165,5 @@ def test_parallel_demo(demo, env, monkeypatch, tmpdir): _exec_file(py_file) if "adjoint" in demo.requirements: + pyadjoint.pause_annotation() pyadjoint.get_working_tape().clear_tape() diff --git a/tests/firedrake/regression/test_restricted_function_space.py b/tests/firedrake/regression/test_restricted_function_space.py index 6dd093f58a..8d8a19a56d 100644 --- a/tests/firedrake/regression/test_restricted_function_space.py +++ b/tests/firedrake/regression/test_restricted_function_space.py @@ -358,7 +358,7 @@ def test_restricted_function_space_extrusion_stokes(ncells): sol_res = Function(W_res) solve(a_res == L_res, sol_res, bcs=[bc_res]) # Compare. - assert assemble(inner(sol_res - sol, sol_res - sol) * dx)**0.5 < 1.e-15 + assert assemble(inner(sol_res - sol, sol_res - sol) * dx)**0.5 < 1.e-14 # -- Actually, the ordering is the same. assert np.allclose(sol_res.subfunctions[0].dat.data_ro_with_halos, sol.subfunctions[0].dat.data_ro_with_halos) assert np.allclose(sol_res.subfunctions[1].dat.data_ro_with_halos, sol.subfunctions[1].dat.data_ro_with_halos)