Skip to content

Commit

Permalink
skip UTs when we do not have parmed, ase, pymatgen (#249)
Browse files Browse the repository at this point in the history
* skip UTs when we do not have parmed, ase, pymatgen

* fix bug of ase fmt

* Update tests/test_amber_md.py

Co-authored-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>

* Update tests/test_pymatgen_molecule.py

Co-authored-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>

* Update tests/test_ase_traj.py

Co-authored-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>

Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>
Co-authored-by: Han Wang <92130845+wanghan-iapcm@users.noreply.github.com>
Co-authored-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
4 people authored Feb 25, 2022
1 parent 4866a2f commit b62f67a
Show file tree
Hide file tree
Showing 71 changed files with 30 additions and 9 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 8 additions & 2 deletions tests/test_amber_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import shutil
from context import dpdata
from comp_sys import CompLabeledSys, IsPBC

try:
import parmed
except ModuleNotFoundError:
skip_parmed_related_test=True
else:
skip_parmed_related_test=False

class TestAmberMD(unittest.TestCase, CompLabeledSys, IsPBC):
def setUp (self) :
Expand All @@ -19,6 +24,7 @@ def tearDown(self) :
if os.path.exists('tmp.deepmd.npy'):
shutil.rmtree('tmp.deepmd.npy')

@unittest.skipIf(skip_parmed_related_test,"skip parmed related test. install parmed to fix")
class TestAmberMDTarget(unittest.TestCase, CompLabeledSys, IsPBC):
def setUp(self):
ll="amber/corr/low_level"
Expand All @@ -35,4 +41,4 @@ def setUp(self):
self.v_places = 6

if __name__ == '__main__':
unittest.main()
unittest.main()
18 changes: 13 additions & 5 deletions tests/test_ase_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,31 @@
import unittest
from context import dpdata
from comp_sys import CompLabeledSys, IsPBC
try:
import ase
except ModuleNotFoundError:
skip_ase = True
else:
skip_ase = False

@unittest.skipIf(skip_ase,"skip ase related test. install ase to fix")
class TestASEtraj1(unittest.TestCase, CompLabeledSys, IsPBC):
def setUp (self) :
self.multi_systems = dpdata.MultiSystems.from_file('ase/HeAlO.traj', fmt='ase/structure')
self.multi_systems = dpdata.MultiSystems.from_file('ase_traj/HeAlO.traj', fmt='ase_traj/structure')
self.system_1 = self.multi_systems.systems['Al0He4O0']
self.system_2 = dpdata.LabeledSystem('ase/Al0He4O0', fmt='deepmd')
self.system_2 = dpdata.LabeledSystem('ase_traj/Al0He4O0', fmt='deepmd')
self.places = 6
self.e_places = 6
self.f_places = 6
self.v_places = 4

@unittest.skipIf(skip_ase,"skip ase related test. install ase to fix")
class TestASEtraj1(unittest.TestCase, CompLabeledSys, IsPBC):
def setUp (self) :
self.system_temp0 = dpdata.MultiSystems.from_file(file_name='ase/HeAlO.traj', fmt='ase/structure')
self.system_temp0 = dpdata.MultiSystems.from_file(file_name='ase_traj/HeAlO.traj', fmt='ase/structure')
self.system_1 = self.system_temp0.systems['Al2He1O3'] # .sort_atom_types()
self.system_temp1 = dpdata.LabeledSystem('ase/Al2He1O3', fmt='deepmd')
self.system_temp2 = dpdata.LabeledSystem('ase/Al4He4O6', fmt='deepmd')
self.system_temp1 = dpdata.LabeledSystem('ase_traj/Al2He1O3', fmt='deepmd')
self.system_temp2 = dpdata.LabeledSystem('ase_traj/Al4He4O6', fmt='deepmd')
self.system_temp3 = dpdata.MultiSystems(self.system_temp2, self.system_temp1)
self.system_2 = self.system_temp3.systems['Al2He1O3']
self.places = 6
Expand Down
11 changes: 9 additions & 2 deletions tests/test_pymatgen_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
import numpy as np
import unittest
from context import dpdata
try:
import pymatgen
except ModuleNotFoundError:
skip_pymatgen=True
else:
skip_pymatgen=False

@unittest.skipIf(skip_pymatgen,"skip pymatgen related test. install pymatgen to fix")
class TestPOSCARCart(unittest.TestCase):

def setUp(self):
self.system = dpdata.System()
self.system.from_pymatgen_molecule(os.path.join('pymatgen', 'FA-001.xyz'))
self.system.from_pymatgen_molecule(os.path.join('pymatgen_data', 'FA-001.xyz'))
self.assertEqual(list(self.system["atom_types"]), [0, 1, 2, 1, 1, 2, 1, 1])

def test_poscar_to_molecule(self):
tmp_system = dpdata.System()
tmp_system.from_vasp_poscar(os.path.join('pymatgen', 'mol2.vasp'))
tmp_system.from_vasp_poscar(os.path.join('pymatgen_data', 'mol2.vasp'))
natoms = len(tmp_system['coords'][0])
tmpcoord = tmp_system['coords'][0]
cog = np.average(tmpcoord, axis = 0)
Expand Down

0 comments on commit b62f67a

Please sign in to comment.