Skip to content

Commit

Permalink
#476 #470 Add unit test for -ot option (online lindemann calculation)
Browse files Browse the repository at this point in the history
  • Loading branch information
N720720 committed Jun 9, 2024
1 parent 0dc4bc3 commit 9238f29
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/test_example/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_t_flag():

def test_m_flag():
flag = "-m"
res_str = "memory use: \nFlag -t (per_trj) will use 0.0034 GB\nFlag -f (per_frames) will use 0.0034 GB\nFlag -a (per_atoms) will use 0.0058 GB\n"
res_str = "memory use: \nFlag -t (per_trj) will use 0.0034 GB\n\nFlag -ot (per_trj) will use 0.0008 GB\nFlag -f (per_frames) will use 0.0034 GB\nFlag -a (per_atoms) will use 0.0058 GB\n"
trajectory = ["tests/test_example/459_02.lammpstrj"]
single_process_and_multiprocess(trajectory, flag, res_str)

Expand Down
24 changes: 20 additions & 4 deletions tests/test_example/test_numeric.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest

from lindemann.index import per_atoms, per_frames, per_trj
from lindemann.index import online_trj, per_atoms, per_frames, per_trj
from lindemann.trajectory import read

"Testing the individal parts of the index module, its possible to change the test setup for individual modules"
Expand All @@ -20,15 +20,31 @@
),
],
)
# def test_setup(trajectory: str, lindemannindex: float) -> bool:


def test_tra(trajectory, lindemannindex):
"""Example test with parametrization."""
frame = read.frames(trajectory)
assert np.isclose(per_trj.calculate(frame), lindemannindex)


@pytest.mark.parametrize(
("trajectory", "lindemannindex"),
[
(
"tests/test_example/459_01.lammpstrj",
0.025923892565654555,
),
(
"tests/test_example/459_02.lammpstrj",
0.026426709832984754,
),
],
)
def test_online_tra(trajectory, lindemannindex):
"""Example test with parametrization."""
pipeline, data = read.trajectory(trajectory)
assert np.isclose(online_trj.calculate(pipeline, data), lindemannindex)


@pytest.mark.parametrize(
("trajectory", "lindemannindex"),
[
Expand Down

0 comments on commit 9238f29

Please sign in to comment.