Skip to content

Commit

Permalink
#476 #470 Add unit test for -of option (online lindemann calculation …
Browse files Browse the repository at this point in the history
…per frame)
  • Loading branch information
N720720 committed Jun 10, 2024
1 parent 89fa13e commit 59d6bc0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/test_example/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_all_flags_multiprocess():

def test_a_p_flags():
trajectory = ["tests/test_example/459_02.lammpstrj"]
result_str = "lindemann index per"
result_str = "lindemann_index_per"
for flag in [
"-a",
"-p",
Expand All @@ -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\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"
res_str = "\nFlag -t (per_trj) will use 0.0034 GB\nFlag -ot (per_trj) will use 0.0008 GB\nFlag -f (per_frames) will use 0.0034 GB\nFlag -of (per_frames) will use 0.0008 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
38 changes: 37 additions & 1 deletion 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 online_trj, per_atoms, per_frames, per_trj
from lindemann.index import online_frames, 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 Down Expand Up @@ -81,6 +81,42 @@ def test_frames_middle(trajectory):
assert np.isclose(linde_at_200_per_frames, linde_from_200_trj)


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


@pytest.mark.parametrize(
("trajectory"),
[
("tests/test_example/459_01.lammpstrj"),
("tests/test_example/459_02.lammpstrj"),
],
)
def test_online_frames_middle(trajectory):
"""Example test with parametrization."""
pipeline, data = read.trajectory(trajectory)
test_array = online_frames.calculate(pipeline, data)
linde_from_200_trj = online_trj.calculate(pipeline, data, 201)
linde_at_200_per_frames = test_array[200]
assert np.isclose(linde_at_200_per_frames, linde_from_200_trj)


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

0 comments on commit 59d6bc0

Please sign in to comment.