-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from alchemistry/namd-tests
extended tests
- Loading branch information
Showing
7 changed files
with
169 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[run] | ||
branch = True | ||
omit = | ||
# omit all tests | ||
src/alchemtest/tests/* | ||
# omit the versioneer-installed _version.py | ||
src/alchemtest/_version.py | ||
|
||
[report] | ||
exclude_lines = | ||
# omit lines marked with: # pragma: no cover | ||
pragma: no cover | ||
|
||
# Don't complain about missing debug-only code: | ||
def __unicode__ | ||
def __repr__ | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise AssertionError | ||
raise NotImplementedError | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
|
||
class BaseDatasetTest(object): | ||
# @pytest.fixture(scope="class", | ||
# params = [(load_tyr2ala, ('forward', 'backward'), (1, 1)), | ||
# ]) | ||
# def dataset(self, reques): | ||
# return super().dataset(request) | ||
|
||
def dataset(self, request): | ||
'''The input dataset is specified as: | ||
load_method: The method for loading the dataset. | ||
keys: The keys to the corresponding dataset. | ||
value_length: The expected number of file for each key. | ||
''' | ||
load_method, keys, value_length = request.param | ||
return load_method, keys, value_length | ||
|
||
def test_num_files(self, dataset): | ||
'''Test if the number of files matches with the expected number of | ||
files.''' | ||
load_method, keys, value_length = dataset | ||
for index, key in enumerate(keys): | ||
assert len(load_method().data[key]) == value_length[index] | ||
|
||
def test_file_exist(self, dataset): | ||
'''Test if files do exist.''' | ||
load_method, keys, value_length = dataset | ||
for key in keys: | ||
for file in load_method().data[key]: | ||
if not os.path.isfile(file): | ||
raise AssertionError('Missing file in data set: {}'.format(file)) |
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,38 @@ | ||
'''Tests for all the AMBER datasets''' | ||
import pytest | ||
|
||
from alchemtest.amber import (load_bace_improper, load_bace_example, | ||
load_simplesolvated, load_invalidfiles, ) | ||
|
||
|
||
|
||
from . import BaseDatasetTest | ||
|
||
class TestAMBER(BaseDatasetTest): | ||
@pytest.fixture(scope="class", | ||
params = [(load_bace_improper, ('vdw',), (12,)), | ||
(load_simplesolvated, ('charge', 'vdw'), (5, 12)), | ||
]) | ||
def dataset(self, request): | ||
return super(TestAMBER, self).dataset(request) | ||
|
||
|
||
# difficult -- has sub dicts under 'complex'/'solvated' -> 'decharge', 'recharge', 'vdw' | ||
# class TestBACEexample(BaseDatasetTest): | ||
# @pytest.fixture(scope="class", | ||
# params = [(load_bace_example, ('complex',), (12,)), | ||
# ]) | ||
# def dataset(self, request): | ||
# return super().dataset(request) | ||
|
||
|
||
# class TestInvalidFiles(BaseDatasetTest): | ||
# # can't get the list of list in data | ||
# @pytest.fixture(scope="class", | ||
# params = [(load_invalidfiles, (slice(None),), (6,)), | ||
# ]) | ||
# def dataset(self, request): | ||
# return super().dataset(request) | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,33 +1,30 @@ | ||
'''Tests for all the gromacs dataset''' | ||
import os | ||
import pytest | ||
|
||
from alchemtest.gmx import load_benzene | ||
from alchemtest.gmx import (load_benzene, load_ABFE, | ||
load_expanded_ensemble_case_1, | ||
load_expanded_ensemble_case_2, | ||
load_expanded_ensemble_case_3, | ||
load_water_particle_without_energy, | ||
load_water_particle_with_potential_energy, | ||
load_water_particle_with_total_energy, | ||
) | ||
|
||
class TestBenzene: | ||
from . import BaseDatasetTest | ||
|
||
|
||
class TestGROMACS(BaseDatasetTest): | ||
@pytest.fixture(scope="class", | ||
params = [(load_benzene, ('Coulomb', 'VDW'), (5, 16)), | ||
(load_ABFE, ('complex', 'ligand'), (30, 20)), | ||
(load_expanded_ensemble_case_1, ('AllStates', ), (1,)), | ||
(load_expanded_ensemble_case_2, ('AllStates', ), (2,)), | ||
(load_expanded_ensemble_case_3, ('AllStates', ), (32,)), | ||
(load_water_particle_without_energy, ('AllStates', ), (38,)), | ||
(load_water_particle_with_potential_energy, ('AllStates', ), (38,)), | ||
(load_water_particle_with_total_energy, ('AllStates', ), (38,)), | ||
]) | ||
def dataset(self, request): | ||
'''The input dataset is specified as: | ||
load_method: The method for loading the dataset. | ||
keys: The keys to the corresponding dataset. | ||
value_length: The expected number of file for each key. | ||
''' | ||
load_method, keys, value_length = request.param | ||
return load_method, keys, value_length | ||
return super(TestGROMACS, self).dataset(request) | ||
|
||
def test_num_files(self, dataset): | ||
'''Test if the number of files matches with the expected number of | ||
files.''' | ||
load_method, keys, value_length = dataset | ||
for index, key in enumerate(keys): | ||
assert len(load_method().data[key]) == value_length[index] | ||
|
||
def test_file_exist(self, dataset): | ||
'''Test if files do exist.''' | ||
load_method, keys, value_length = dataset | ||
for key in keys: | ||
for file in load_method().data[key]: | ||
if not os.path.isfile(file): | ||
raise AssertionError('Missing file in data set: {}'.format(file)) |
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,15 @@ | ||
'''Tests for all the GOMC dataset''' | ||
import pytest | ||
|
||
from alchemtest.gomc import load_benzene | ||
|
||
from . import BaseDatasetTest | ||
|
||
class TestGOMC(BaseDatasetTest): | ||
# note that the GOMC data does not use a dict for data but directly returns | ||
# a list; we can work around this peculiarity by using a slice instead of a key | ||
@pytest.fixture(scope="class", | ||
params = [(load_benzene, (slice(None),), (23,)), | ||
]) | ||
def dataset(self, request): | ||
return super(TestGOMC, self).dataset(request) |
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,15 @@ | ||
'''Tests for all the NAMD datasets''' | ||
import pytest | ||
|
||
from alchemtest.namd import load_tyr2ala, load_idws | ||
|
||
from . import BaseDatasetTest | ||
|
||
|
||
class TestNAMD(BaseDatasetTest): | ||
@pytest.fixture(scope="class", | ||
params = [(load_tyr2ala, ('forward', 'backward'), (1, 1)), | ||
(load_idws, ('forward', ), (2,)), | ||
]) | ||
def dataset(self, request): | ||
return super(TestNAMD, self).dataset(request) |