Skip to content

Commit

Permalink
Style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JHKru committed Feb 22, 2024
1 parent e7941d5 commit eb2f0f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
14 changes: 6 additions & 8 deletions src/springcraft/nma.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ def dcc(enm, mode_subset=None, norm=True, tem=None, tem_factors=K_B):
for 'mode_subset' and 'memory_efficient' are passed to the function.
"""

from springcraft import GNM
from springcraft import ANM
from .gnm import GNM
from .anm import ANM

eig_values, eig_vectors = enm.eigen()
n_nodes = len(enm._coord)
Expand Down Expand Up @@ -327,9 +327,8 @@ def dcc(enm, mode_subset=None, norm=True, tem=None, tem_factors=K_B):
elif all_modes:
# 3N x 3N -> N x 3 x N x 3 -> N x N x 3 x 3
cov = enm.covariance
reshaped = cov.reshape(
cov.shape[0]//3, 3, -1, 3
).swapaxes(1,2)
reshaped = cov.reshape(cov.shape[0]//3, 3, cov.shape[0]//3, 3
).swapaxes(1,2)
# Accept array of any dimension
# -> Sum over diagonals in last two dims
# -> Return any shape (in this case NxN)
Expand All @@ -341,9 +340,8 @@ def dcc(enm, mode_subset=None, norm=True, tem=None, tem_factors=K_B):

# Reshape array of eigenvectors
# (k,3n) -> (k,n,3) for ANMs; (k,n) -> (k,n,1) for GNMs
modes_reshaped = np.reshape(
eig_vectors, (len(mode_subset), -1, num_dim)
)
modes_reshaped = np.reshape(eig_vectors, (len(mode_subset), -1, num_dim)
)
dcc = np.zeros((n_nodes, n_nodes))
for ev, evec in zip(eig_values, modes_reshaped):
dcc += (evec @ evec.T) / ev
Expand Down
18 changes: 7 additions & 11 deletions tests/test_anm.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,9 @@ def test_frequency_fluctuation_dcc(ff_name):
# no temperature weighting
tem_scaling = 1
tem = 1
reference_fluc = np.genfromtxt(
join(data_dir(), ref_fluc),
skip_header=1, delimiter=","
)
reference_fluc = np.genfromtxt(join(data_dir(), ref_fluc),
skip_header=1, delimiter=","
)

# Bio3d -> Mass- and temperature weighting
else:
Expand All @@ -211,14 +210,11 @@ def test_frequency_fluctuation_dcc(ff_name):
reference_masses = np.array(enm_nma_bio3d.rx2["mass"])
reference_freq = np.array(enm_nma_bio3d.rx2["frequencies"])
reference_fluc = np.array(enm_nma_bio3d.rx2["fluctuations"])
reference_fluc_subset = np.array(
bio3d.fluct_nma(enm_nma_bio3d,
mode_inds=r_seq(12,33)
))
reference_fluc_subset = np.array(bio3d.fluct_nma(
enm_nma_bio3d, mode_inds=r_seq(12,33)
))
reference_dcc = np.array(bio3d.dccm(enm_nma_bio3d))
reference_dcc_subset = np.array(
bio3d.dccm(enm_nma_bio3d, nmodes=30)
)
reference_dcc_subset = np.array(bio3d.dccm(enm_nma_bio3d, nmodes=30))

tem_scaling = K_B*N_A
test_nomw = springcraft.ANM(ca, ff)
Expand Down

0 comments on commit eb2f0f1

Please sign in to comment.