From 9ab1c478c463d901d07fd5c099a974cb64df2bb1 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 4 Jan 2024 17:10:59 +0100 Subject: [PATCH 1/4] Add more tests for base --- tests/test_base.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_base.py b/tests/test_base.py index cbaa314..ce06e21 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -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) @@ -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.assertEqual(self.lmp.version, 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() From b1a79fcc9d883ca31d7bd643c834d2c0d5d96a5b Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 4 Jan 2024 17:14:28 +0100 Subject: [PATCH 2/4] Add more cuncurrent tests --- tests/test_concurrent.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_concurrent.py b/tests/test_concurrent.py index 48f390d..7ae0b58 100644 --- a/tests/test_concurrent.py +++ b/tests/test_concurrent.py @@ -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() @@ -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.assertEqual(self.lmp.version.result(), 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() From 5827b2395e07445fef77b7bdfe614cc7b8e9311f Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 4 Jan 2024 17:21:13 +0100 Subject: [PATCH 3/4] fix older version --- tests/test_base.py | 2 +- tests/test_concurrent.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_base.py b/tests/test_base.py index ce06e21..51869a2 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -98,7 +98,7 @@ def test_cmdarg_options(self): self.assertTrue(os.path.isfile(self.citation_file)) def test_version(self): - self.assertEqual(self.lmp.version, 20230802) + self.assertTrue(self.lmp.version in [20220623, 20230802]) def test_extract_global(self): self.assertEqual( diff --git a/tests/test_concurrent.py b/tests/test_concurrent.py index 7ae0b58..7931f2c 100644 --- a/tests/test_concurrent.py +++ b/tests/test_concurrent.py @@ -94,7 +94,7 @@ def test_cmdarg_options(self): self.assertTrue(os.path.isfile(self.citation_file)) def test_version(self): - self.assertEqual(self.lmp.version.result(), 20230802) + self.assertTrue(self.lmp.version.result() in [20220623, 20230802]) def test_extract_global(self): self.assertEqual( From e95acfbe1971e0a66f6e491f4e589a77b7e9e525 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 4 Jan 2024 17:26:15 +0100 Subject: [PATCH 4/4] handle Python 3.9 bug --- tests/test_pylammpsmpi_local.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_pylammpsmpi_local.py b/tests/test_pylammpsmpi_local.py index f2a831f..83623db 100644 --- a/tests/test_pylammpsmpi_local.py +++ b/tests/test_pylammpsmpi_local.py @@ -5,6 +5,7 @@ import unittest import numpy as np import os +import sys from pylammpsmpi import LammpsLibrary @@ -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):