-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
131 lines (114 loc) · 3.3 KB
/
Copy pathtest_utils.py
File metadata and controls
131 lines (114 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import unittest
import yaml
import numpy as np
from pathlib import Path
import MPP
import MPP.run as run_module
config_dir = "tests/data/"
root = "tests/data/HP35/input/"
SYSTEMS = [
"HP35",
"PDZ3",
"aSyn",
"HP35_stoch",
]
SETUPS = [
"t",
"kl",
"t_js",
"kl_js",
"gpcca",
]
with open(f"{config_dir}lumpings.yaml") as f:
lumpings = yaml.safe_load(f)
def get_d(system, setup, rmsd=False):
d = run_module.Data(
f"tests/data/{system}/input/config.yml"
)
d.setup_mpp(
lumpings[setup]["kernel similarity"],
lumpings[setup]["feature kernel"],
)
if setup == "gpcca":
d.perform_gpcca("ref", f"{root}{system}/{setup}/Z.npy")
else:
d.perform_mpp(f"{root}{system}/{setup}/Z.npy")
if rmsd:
d.mpp.load_rmsd(f"{root}{system}/{setup}/rmsd.npy")
return d
class TestProperties(unittest.TestCase):
def setUp(self):
self.d = get_d("HP35", "t")
self.mpp = self.d.mpp
def test_Z_to_linkage(self):
linkage = MPP.utils.Z_to_linkage(self.mpp.Z[self.mpp.n_i])
expected_linkage = np.load(
Path(__file__).parent
/ "data"
/ "HP35"
/ "expected_output"
/ "t"
/ "linkage.npy"
)
np.testing.assert_allclose(linkage, expected_linkage)
def test_linkage_to_Z(self):
expected_linkage = np.load(
Path(__file__).parent
/ "data"
/ "HP35"
/ "expected_output"
/ "t"
/ "linkage.npy"
)
z_i, full_pop = MPP.utils.linkage_to_Z(expected_linkage, self.mpp.pop)
expected_z = np.load(
Path(__file__).parent / "data" / "HP35" / "expected_output" / "t" / "Z.npy"
)
np.testing.assert_allclose(z_i, expected_z[0])
def test_calc_full_tmat(self):
expected_tmat = np.load(
Path(__file__).parent
/ "data"
/ "HP35"
/ "expected_output"
/ "t"
/ "full_tmat.npy"
)
expected_pop = np.load(
Path(__file__).parent
/ "data"
/ "HP35"
/ "expected_output"
/ "t"
/ "full_pop.npy"
)
full_tmat, full_pop = MPP.utils.calc_full_tmat(
self.mpp.tmat, self.mpp.pop, self.mpp.Z
)
np.testing.assert_allclose(full_tmat, expected_tmat)
np.testing.assert_allclose(full_pop, expected_pop)
def test_Z_to_mask(self):
expected_mask = np.load(
Path(__file__).parent
/ "data"
/ "HP35"
/ "expected_output"
/ "t"
/ "full_mask.npy"
)
full_mask = MPP.utils.Z_to_mask(self.mpp.Z[0])
np.testing.assert_allclose(full_mask, expected_mask)
class TestFullFeature(unittest.TestCase):
def setUp(self):
self.d = get_d("HP35", "t_js")
def test_full_feature_from_Z(self):
expected_full_feature = np.load(
Path(__file__).parent
/ "data"
/ "HP35"
/ "expected_output"
/ "t_js"
/ "full_feature.npy"
)
full_feature = self.d.feature_kernel.full_feature_from_Z(self.d.mpp.Z)
np.testing.assert_allclose(full_feature, expected_full_feature)