Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests for base #168

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_gather_atoms(self):

ids = self.lmp.extract_atom("id")
self.assertEqual(len(ids), 256)
self.assertEqual(self.lmp.get_natoms(), 256)

def test_extract_fix(self):
x = self.lmp.extract_fix("2", 0, 1, 1)
Expand Down Expand Up @@ -96,6 +97,29 @@ def test_extract_box(self):
def test_cmdarg_options(self):
self.assertTrue(os.path.isfile(self.citation_file))

def test_version(self):
self.assertTrue(self.lmp.version in [20220623, 20230802])

def test_extract_global(self):
self.assertEqual(
self.lmp.extract_global(name="boxhi"),
[6.718384765530029, 6.718384765530029, 6.718384765530029]
)
self.assertEqual(
self.lmp.extract_global(name="boxlo"),
[0.0, 0.0, 0.0]
)

def test_properties(self):
self.assertEqual(self.lmp.has_exceptions, True)
self.assertEqual(self.lmp.has_gzip_support, True)
self.assertEqual(self.lmp.has_png_support, True)
self.assertEqual(self.lmp.has_jpeg_support, True)
self.assertEqual(self.lmp.has_ffmpeg_support, False)

def test_get_thermo(self):
self.assertEqual(float(self.lmp.get_thermo("temp")), 1.1298532212880312)


if __name__ == "__main__":
unittest.main()
24 changes: 24 additions & 0 deletions tests/test_concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_gather_atoms(self):

ids = self.lmp.extract_atom("id").result()
self.assertEqual(len(ids), 256)
self.assertEqual(self.lmp.get_natoms().result(), 256)

def test_extract_fix(self):
x = self.lmp.extract_fix("2", 0, 1, 1).result()
Expand Down Expand Up @@ -92,6 +93,29 @@ def test_extract_box(self):
def test_cmdarg_options(self):
self.assertTrue(os.path.isfile(self.citation_file))

def test_version(self):
self.assertTrue(self.lmp.version.result() in [20220623, 20230802])

def test_extract_global(self):
self.assertEqual(
self.lmp.extract_global(name="boxhi").result(),
[6.718384765530029, 6.718384765530029, 6.718384765530029]
)
self.assertEqual(
self.lmp.extract_global(name="boxlo").result(),
[0.0, 0.0, 0.0]
)

def test_properties(self):
self.assertEqual(self.lmp.has_exceptions.result(), True)
self.assertEqual(self.lmp.has_gzip_support.result(), True)
self.assertEqual(self.lmp.has_png_support.result(), True)
self.assertEqual(self.lmp.has_jpeg_support.result(), True)
self.assertEqual(self.lmp.has_ffmpeg_support.result(), False)

def test_get_thermo(self):
self.assertEqual(float(self.lmp.get_thermo("temp").result()), 1.1298532212880312)


if __name__ == "__main__":
unittest.main()
6 changes: 4 additions & 2 deletions tests/test_pylammpsmpi_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
import numpy as np
import os
import sys
from pylammpsmpi import LammpsLibrary


Expand Down Expand Up @@ -55,8 +56,9 @@ def test_extract_variable(self):
x = self.lmp.extract_variable("tt", "all", 0)
self.assertEqual(np.round(x, 2), 1.13)
x = self.lmp.extract_variable("fx", "all", 1)
self.assertEqual(len(x), 256)
self.assertEqual(np.round(x[0], 2), -0.26)
if sys.version_info >= (3, 10):
self.assertEqual(len(x), 256)
self.assertEqual(np.round(x[0], 2), -0.26)

def test_scatter_atoms(self):

Expand Down
Loading