Enable PyLammps unit test, require NumPy

This commit is contained in:
Richard Berger
2022-02-03 19:50:59 -05:00
parent 22efbaf977
commit 75f389f70c
2 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,13 @@
import sys,os,unittest
import os,unittest
from lammps import PyLammps
try:
import numpy
NUMPY_INSTALLED = True
except ImportError:
NUMPY_INSTALLED = False
@unittest.skipIf(not NUMPY_INSTALLED, "numpy is not available")
class PythonPyLammps(unittest.TestCase):
def setUp(self):
machine = None
@ -49,8 +56,8 @@ class PythonPyLammps(unittest.TestCase):
self.assertEqual(self.pylmp.lmp.create_atoms(2, id=None, type=types, x=x), 2)
self.assertEqual(self.pylmp.system.natoms, 2)
self.assertEqual(len(self.pylmp.atoms), 2)
self.assertEqual(self.pylmp.atoms[0].position, tuple(x[0:3]))
self.assertEqual(self.pylmp.atoms[1].position, tuple(x[3:6]))
numpy.testing.assert_array_equal(self.pylmp.atoms[0].position, tuple(x[0:3]))
numpy.testing.assert_array_equal(self.pylmp.atoms[1].position, tuple(x[3:6]))
self.assertEqual(self.pylmp.last_run, None)