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

skip UTs when we do not have parmed, ase, pymatgen #249

Merged
merged 5 commits into from
Feb 25, 2022
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
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