-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #236. This PR puts all the tests in the same directory, with a subdirectory for the adjoint ones. Various parts of the conftest are no longer needed. I also plan to crank up the test coverage on a few modules in this PR.
- Loading branch information
1 parent
5303c0d
commit 7f61988
Showing
19 changed files
with
139 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
Global pytest configuration for adjoint tests. | ||
**Disclaimer: some functions copied from firedrake/src/tests/conftest.py | ||
""" | ||
|
||
import pyadjoint | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def check_empty_tape(request): | ||
""" | ||
Check that the tape is empty at the end of each module | ||
**Disclaimer: copied from firedrake/src/tests/conftest.py | ||
""" | ||
|
||
def fin(): | ||
tape = pyadjoint.get_working_tape() | ||
if tape is not None: | ||
assert len(tape.get_blocks()) == 0 | ||
|
||
request.addfinalizer(fin) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def handle_taping(): | ||
""" | ||
**Disclaimer: copied from | ||
firedrake/tests/regression/test_adjoint_operators.py | ||
""" | ||
yield | ||
tape = pyadjoint.get_working_tape() | ||
tape.clear_tape() | ||
|
||
|
||
@pytest.fixture(autouse=True, scope="module") | ||
def handle_annotation(): | ||
""" | ||
Since importing firedrake-adjoint modifies a global variable, we need to | ||
pause annotations at the end of the module. | ||
**Disclaimer: copied from | ||
firedrake/tests/regression/test_adjoint_operators.py | ||
""" | ||
if not pyadjoint.annotate_tape(): | ||
pyadjoint.continue_annotation() | ||
yield | ||
if pyadjoint.annotate_tape(): | ||
pyadjoint.pause_annotation() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.