Skip to content

Commit 13129d8

Browse files
Merge pull request #26 from openforcefield/inverting-matri
flipping sign of matrix to match expected
2 parents 18e28c4 + 3da3270 commit 13129d8

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

arsenic/stats.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ def form_edge_matrix(g, label, step=None, action=None, node_label=None):
217217
for a, b in g.edges:
218218
i = node_name_to_index[a]
219219
j = node_name_to_index[b]
220-
matrix[i, j] = g.edges[a, b][label]
220+
matrix[j, i] = g.edges[a, b][label]
221221
if action == 'symmetrize':
222-
matrix[j, i] = matrix[i, j]
222+
matrix[i, j] = matrix[j, i]
223223
elif action == 'antisymmetrize':
224-
matrix[j, i] = -matrix[i, j]
224+
matrix[i, j] = -matrix[j, i]
225225
elif action is None:
226226
pass
227227
else:

arsenic/tests/test_stats.py

+28-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_mle_easy(input_absolutes=[-14., -13., -9.]):
1717
edges = [(0, 1), (0, 2), (2, 1)]
1818
for a, b in edges:
1919
noise = np.random.uniform(low=-1., high=1.)
20-
diff = input_absolutes[a] - input_absolutes[b] + noise
20+
diff = input_absolutes[b] - input_absolutes[a] + noise
2121
g.add_edge(a, b, f_ij=diff, f_dij=0.5+np.abs(noise))
2222

2323
output_absolutes, C = stats.mle(g, factor='f_ij', node_factor='f_i')
@@ -49,7 +49,7 @@ def test_mle_hard(input_absolutes=[-14., -13., -9.]):
4949
edges = [(0, 1), (0, 2), (2, 1)]
5050
for a, b in edges:
5151
noise = np.random.uniform(low=-1., high=1.)
52-
diff = input_absolutes[a] - input_absolutes[b] + noise
52+
diff = input_absolutes[b] - input_absolutes[a] + noise
5353
g.add_edge(a, b, f_ij=diff, f_dij=0.5+np.abs(noise))
5454

5555
output_absolutes, C = stats.mle(g, factor='f_ij', node_factor='f_i')
@@ -74,8 +74,8 @@ def test_mle_relative(input_absolutes=[-14., -13., -9.]):
7474
# Don't assign any absolute values
7575
edges = [(0, 1), (0, 2), (2, 1)]
7676
for a, b in edges:
77-
noise = np.random.uniform(low=-1., high=1.)
78-
diff = input_absolutes[a] - input_absolutes[b] + noise
77+
noise = np.random.uniform(low=-0.5, high=0.5)
78+
diff = input_absolutes[b] - input_absolutes[a] + noise
7979
g.add_edge(a, b, f_ij=diff, f_dij=0.5+np.abs(noise))
8080

8181
output_absolutes, C = stats.mle(g, factor='f_ij', node_factor='f_i')
@@ -89,3 +89,27 @@ def test_mle_relative(input_absolutes=[-14., -13., -9.]):
8989
assert np.abs(true_diff - mle_diff) < 1., f"Relative\
9090
difference from MLE: {mle_diff} is too far from the\
9191
input difference, {true_diff}"
92+
93+
94+
def test_correlation_positive():
95+
""" Test that the absolute DG plots have the correct signs, and statistics within reasonable agreement to the example data in `arsenic/data/example.csv`
96+
97+
"""
98+
from arsenic import plotting, stats, wrangle
99+
import os
100+
print(os.system('pwd'))
101+
import numpy as np
102+
fe = wrangle.FEMap('arsenic/data/example.csv')
103+
104+
x_data = np.asarray([node[1]['exp_DG'] for node in fe.graph.nodes(data=True)])
105+
y_data = np.asarray([node[1]['calc_DG'] for node in fe.graph.nodes(data=True)])
106+
xerr = np.asarray([node[1]['exp_dDG'] for node in fe.graph.nodes(data=True)])
107+
yerr = np.asarray([node[1]['calc_dDG'] for node in fe.graph.nodes(data=True)])
108+
109+
s = stats.bootstrap_statistic(x_data, y_data, xerr, yerr, statistic='rho')
110+
assert 0 < s['mle'] < 1, 'Correlation must be positive for this data'
111+
112+
for stat in ['R2','rho']:
113+
s = stats.bootstrap_statistic(x_data, y_data, xerr, yerr, statistic=stat)
114+
# all of the statistics for this example is between 0.61 and 0.84
115+
assert 0.5 < s['mle'] < 0.9, f"Correlation must be positive for this data. {stat} is {s['mle']}"

devtools/conda-envs/test_env.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ dependencies:
1010
- pytest-cov
1111
- codecov
1212
- networkx
13+
- numpy
14+
- matplotlib
15+
- seaborn
16+
- plotly
17+
- scikit-learn
1318

1419
# Pip-only installs
15-
#- pip:
16-
# - codecov
20+
#- pip:
21+
# - codecov
1722

devtools/travis-ci/before_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ else
1515
MINICONDA=Miniconda3-latest-Linux-x86_64.sh
1616
fi
1717
MINICONDA_HOME=$HOME/miniconda
18-
MINICONDA_MD5=$(curl -s https://repo.continuum.io/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *<td>\(.*\)<\/td> */\1/p')
18+
MINICONDA_MD5=$(wget -qO- https://repo.anaconda.com/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *<td>\(.*\)<\/td> */\1/p')
1919
wget -q https://repo.continuum.io/miniconda/$MINICONDA
2020
if [[ $MINICONDA_MD5 != $(md5sum $MINICONDA | cut -d ' ' -f 1) ]]; then
2121
echo "Miniconda MD5 mismatch"

0 commit comments

Comments
 (0)