Skip to content

Commit

Permalink
Merge pull request #250 from choderalab/remove-pymbar-datasets
Browse files Browse the repository at this point in the history
Remove abandoned pymbar-datasets code
  • Loading branch information
jchodera committed Dec 31, 2016
2 parents 8de0494 + 5228ac6 commit dc0fd3f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 191 deletions.
26 changes: 5 additions & 21 deletions pymbar/tests/test_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ def load_exponentials(n_states, n_samples):
return name, u_kn, N_k_output, s_n

def _test(data_generator):
try:
name, U, N_k, s_n = data_generator()
except IOError as exc:
raise(SkipTest("Cannot load dataset; skipping test. Try downloading pymbar-datasets GitHub repository and setting PYMBAR-DATASETS environment variable. Error was '%s'" % exc))
except ImportError as exc:
raise(SkipTest("Error importing pytables to load dataset; skipping test. Error was '%s'" % exc))
name, U, N_k, s_n = data_generator()
print(name)
mbar = pymbar.MBAR(U, N_k)
fij1, dfij1, Theta_ij = mbar.getFreeEnergyDifferences(uncertainty_method="svd")
Expand All @@ -45,31 +40,20 @@ def _test(data_generator):

eq(fij0, fij1, decimal=8)
eq(dfij0, dfij1, decimal=8)

eq(fij0, fij2, decimal=8)
eq(dfij0, dfij2, decimal=8)



def test_100x100_oscillators():
data_generator = lambda : load_oscillators(100, 100)
_test(data_generator)

def test_200x50_oscillators():
data_generator = lambda : load_oscillators(200, 50)
_test(data_generator)

def test_200x50_exponentials():
data_generator = lambda : load_exponentials(200, 50)
_test(data_generator)


def test_gas():
raise(SkipTest("skip"))
data_generator = pymbar.testsystems.pymbar_datasets.load_gas_data
_test(data_generator)

def test_8proteins():
raise(SkipTest("skip"))
data_generator = pymbar.testsystems.pymbar_datasets.load_8proteins_data
_test(data_generator)
32 changes: 7 additions & 25 deletions pymbar/tests/test_mbar_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ def load_exponentials(n_states, n_samples, provide_test=False):
return returns

def _test(data_generator):
try:
name, U, N_k, s_n = data_generator()
except IOError as exc:
raise(SkipTest("Cannot load dataset; skipping test. Try downloading pymbar-datasets GitHub repository and setting PYMBAR-DATASETS environment variable. Error was '%s'" % exc))
except ImportError as exc:
raise(SkipTest("Error importing pytables to load external dataset; skipping test. Error was '%s'" % exc))
name, U, N_k, s_n = data_generator()
print(name)
mbar = pymbar.MBAR(U, N_k)
eq(pymbar.mbar_solvers.mbar_gradient(U, N_k, mbar.f_k), np.zeros(N_k.shape), decimal=8)
Expand All @@ -45,41 +40,28 @@ def _test(data_generator):
# Test against old MBAR code.
mbar0 = pymbar.old_mbar.MBAR(U, N_k)
eq(mbar.f_k, mbar0.f_k, decimal=8)
eq(np.exp(mbar.Log_W_nk), np.exp(mbar0.Log_W_nk), decimal=5)
eq(np.exp(mbar.Log_W_nk), np.exp(mbar0.Log_W_nk), decimal=5)


def test_100x100_oscillators():
data_generator = lambda : load_oscillators(100, 100)
_test(data_generator)

def test_200x50_oscillators():
data_generator = lambda : load_oscillators(200, 50)
_test(data_generator)

def test_200x50_exponentials():
data_generator = lambda : load_exponentials(200, 50)
_test(data_generator)

def test_gas():
data_generator = pymbar.testsystems.pymbar_datasets.load_gas_data
_test(data_generator)

def test_8proteins():
data_generator = pymbar.testsystems.pymbar_datasets.load_8proteins_data
_test(data_generator)

def test_k69():
data_generator = pymbar.testsystems.pymbar_datasets.load_k69_data
_test(data_generator)


def test_subsampling():
name, u_kn, N_k, s_n = load_exponentials(5, 20000)
mbar = pymbar.MBAR(u_kn, N_k)
u_kn_sub, N_k_sub = pymbar.mbar_solvers.subsample_data(u_kn, N_k, s_n, 2)
mbar_sub = pymbar.MBAR(u_kn_sub, N_k_sub)
eq(mbar.f_k, mbar_sub.f_k, decimal=2)

def test_protocols():
'''Test that free energy is moderatley equal to analytical solution, independent of solver protocols'''
#Supress the warnings when jacobian and Hessian information is not used in a specific solver
Expand All @@ -92,13 +74,13 @@ def test_protocols():
fa = fa[1:] - fa[0]

#scipy.optimize.minimize methods, same ones that are checked for in mbar_solvers.py
subsampling_protocols = ["L-BFGS-B", "dogleg", "CG", "BFGS", "Newton-CG", "TNC", "trust-ncg", "SLSQP"]
subsampling_protocols = ["L-BFGS-B", "dogleg", "CG", "BFGS", "Newton-CG", "TNC", "trust-ncg", "SLSQP"]
solver_protocols = ['hybr', 'lm'] #scipy.optimize.root methods. Omitting methods which do not use the Jacobian
for subsampling_protocol in subsampling_protocols:
for solver_protocol in solver_protocols:
#Solve MBAR with zeros for initial weights
mbar = pymbar.MBAR(u_kn, N_k, subsampling_protocol=({'method':subsampling_protocol},), solver_protocol=({'method':solver_protocol},))
#Solve MBAR with the correct f_k used for the inital weights
#Solve MBAR with the correct f_k used for the inital weights
mbar = pymbar.MBAR(u_kn, N_k, initial_f_k=mbar.f_k, subsampling_protocol=({'method':subsampling_protocol},), solver_protocol=({'method':solver_protocol},))
fe, fe_sigma, Theta_ij = mbar.getFreeEnergyDifferences()
fe, fe_sigma = fe[0,1:], fe_sigma[0,1:]
Expand Down
1 change: 0 additions & 1 deletion pymbar/testsystems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
from pymbar.testsystems.exponential_distributions import ExponentialTestCase
from pymbar.testsystems.timeseries import correlated_timeseries_example
from pymbar.testsystems.gaussian_work import gaussian_work_example
from pymbar.testsystems.pymbar_datasets import load_gas_data, load_8proteins_data
144 changes: 0 additions & 144 deletions pymbar/testsystems/pymbar_datasets.py

This file was deleted.

0 comments on commit dc0fd3f

Please sign in to comment.