Skip to content

Commit

Permalink
Merge test_molecular_dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Feb 25, 2025
1 parent 0a9f7ee commit e063d2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 111 deletions.
20 changes: 14 additions & 6 deletions MDANSE/Tests/UnitTests/test_analysis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import numpy as np
import pytest
from MDANSE.MolecularDynamics.Analysis import (AnalysisError,
Expand All @@ -8,16 +7,22 @@
radius_of_gyration)

COORDS = [
np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]]),
np.array([[1, 1, 1], [2, 1, 1], [3, 1, 1]]),
np.array([[1, 1, 1], [2, 1, 1], [8, 1, 1]]),
np.array([[1, 2, 1], [2, 1, 1], [10, 5, 5], [1, 1, 2]]),
np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]], dtype=float),
np.array([[1, 1, 1], [2, 1, 1], [3, 1, 1]], dtype=float),
np.array([[1, 1, 1], [2, 1, 1], [8, 1, 1]], dtype=float),
np.array([[1, 2, 1], [2, 1, 1], [10, 5, 5], [1, 1, 2]], dtype=float),
np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0],
[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]], dtype=float),
np.array([[1, 1, 1], [2, 1, 1], [2, 2, 1], [1, 2, 1],
[1, 1, 2], [2, 1, 2], [2, 2, 2], [1, 2, 2]], dtype=float),
]

@pytest.mark.parametrize("coords,masses,root,expected", [
((COORDS[1], COORDS[0]), None, False, 20/3),
((COORDS[1], COORDS[0]), [3, 10, 1], False, 80/14),
((COORDS[2], COORDS[0]), None, True, 5),
((COORDS[4], COORDS[5]), None, True, np.sqrt(3))
((COORDS[4], COORDS[5]), None, False, 3)
])
def test_mean_square_deviation(coords, masses, root, expected):
msd = mean_square_deviation(*coords, masses, root)
Expand All @@ -40,6 +45,7 @@ def test_mean_square_displacement(coords, n_configs, expected):
@pytest.mark.parametrize("coords, root, expected", [
(COORDS[3], False, 19.625),
(COORDS[3], True, np.sqrt(19.625)),
(COORDS[4], False, 0.75),
])
def test_mean_square_fluctuation(coords, root, expected):
msf = mean_square_fluctuation(coords, root=root)
Expand All @@ -50,7 +56,9 @@ def test_mean_square_fluctuation(coords, root, expected):
(COORDS[3], [1, 1, 5, 1], False, 24.15625),
(COORDS[3], None, True, np.sqrt(19.625)),
(COORDS[3], [1, 1, 5, 1], True, np.sqrt(24.15625)),
(COORDS[4], None, True, np.sqrt(0.75)),
(COORDS[4], [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0], True, np.sqrt(0.5))
])
def test_radius_of_gyration_no_masses_no_root(coords, masses, root, expected):
def test_radius_of_gyration(coords, masses, root, expected):
rog = radius_of_gyration(coords, masses, root=root)
assert rog == expected
105 changes: 0 additions & 105 deletions MDANSE/Tests/UnitTests/test_molecular_dynamics.py

This file was deleted.

0 comments on commit e063d2c

Please sign in to comment.