-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fixed logic error in p_transfer: due to wrong indentation, only ONE Gsolv was analyzed and unless it had been pre-analyzed, the function would fail with "results.DeltaA does not contain Gibbs" - added tests for p_transfer() and for the failure cases of pOW and pCW (these tests do NOT use pybol) - use top level package resources in tests to find the testing_resources - moved the logic for reading pickle files created with Python 2 under Python 3 from the tests to the main code (restart.Journalled.load()) - reST fixes and updates (aanalyze_alchemlyb() and others) - update CHANGES
- Loading branch information
Showing
8 changed files
with
150 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
# tests for MDPOW | ||
|
||
import py.path | ||
from pkg_resources import resource_filename | ||
|
||
|
||
RESOURCES = py.path.local(resource_filename(__name__, 'testing_resources')) | ||
|
||
MOLECULES = { | ||
"benzene": RESOURCES.join("molecules", "benzene"), | ||
} | ||
STATES = { | ||
"FEP": RESOURCES.join("states", "FEP"), | ||
"base": RESOURCES.join("states", "base"), | ||
"md_npt": RESOURCES.join("states", "FEP"), | ||
} | ||
CONFIGURATIONS = RESOURCES.join("test_configurations") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
from __future__ import absolute_import | ||
|
||
import sys | ||
from six.moves import reload_module | ||
|
||
import pytest | ||
|
||
|
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,81 @@ | ||
from __future__ import absolute_import | ||
|
||
import pytest | ||
|
||
import os.path | ||
import shutil | ||
import copy | ||
|
||
import mdpow.fep | ||
|
||
from . import STATES | ||
|
||
@pytest.fixture | ||
def FEP_dir(tmpdir): | ||
name = STATES['FEP'].basename # a py.path.local | ||
fepdir = tmpdir.join(name) # a py.path.local | ||
shutil.copytree(STATES['FEP'].strpath, fepdir.strpath) | ||
assert os.path.isdir(fepdir.strpath) | ||
return fepdir | ||
|
||
def setup_Ghyd(fepdir): | ||
basedir = fepdir.join("benzene") | ||
gsolv = basedir.join("FEP", "water", "Gsolv.fep") | ||
G = mdpow.fep.Ghyd(filename=gsolv.strpath) | ||
# patch paths | ||
G.basedir = basedir.strpath | ||
G.filename = gsolv.strpath | ||
return G | ||
|
||
|
||
@pytest.fixture | ||
def Ghyd(FEP_dir): | ||
return setup_Ghyd(FEP_dir) | ||
|
||
@pytest.fixture | ||
def Ghyd_other(FEP_dir): | ||
return setup_Ghyd(FEP_dir) | ||
|
||
def test_load_Ghyd(Ghyd): | ||
assert isinstance(Ghyd, mdpow.fep.Ghyd) | ||
|
||
@pytest.mark.parametrize("kwargs", ( | ||
{}, | ||
{'SI': True, 'estimator': 'alchemlyb', 'method': 'TI'}, | ||
{'SI': False, 'estimator': 'alchemlyb', 'method': 'MBAR', 'force': False}, | ||
{'SI': False, 'estimator': 'mdpow', 'method': 'TI', 'force': True}, | ||
), | ||
ids=["defaults", | ||
"SI=True, estimator='alchemlyb', method='TI'", | ||
"SI=False, estimator='alchemlyb', method='MBAR', force=False", | ||
"SI=False, estimator='mdpow', method='TI', force=True", | ||
] | ||
) | ||
def test_p_transfer(Ghyd, Ghyd_other, kwargs): | ||
"""Test transfer water <-> water with same data.""" | ||
G1 = Ghyd | ||
G2 = Ghyd_other | ||
|
||
transferFE, logPow = mdpow.fep.p_transfer(G1, G2, **kwargs) | ||
|
||
assert transferFE == pytest.approx(0.0) | ||
assert logPow == pytest.approx(0.0) | ||
|
||
def test_p_transfer_wrong_method(Ghyd, Ghyd_other): | ||
"""Test transfer water <-> water with same data.""" | ||
G1 = Ghyd | ||
G2 = Ghyd_other | ||
|
||
with pytest.raises(ValueError, | ||
match="Method MBAR is not implemented in MDPOW, use estimator='alchemlyb'"): | ||
mdpow.fep.p_transfer(G1, G2, estimator="mdpow", method="MBAR") | ||
|
||
|
||
def test_pOW_error(Ghyd, Ghyd_other): | ||
with pytest.raises(ValueError): | ||
mdpow.fep.pOW(Ghyd, Ghyd_other) | ||
|
||
def test_pCW_error(Ghyd, Ghyd_other): | ||
with pytest.raises(ValueError): | ||
mdpow.fep.pCW(Ghyd, Ghyd_other) | ||
|