Skip to content

Commit b5fbee0

Browse files
committed
test nopdb for other formats
1 parent c3017e5 commit b5fbee0

18 files changed

+64
-53
lines changed

tests/comp_sys.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,12 @@ def test_virial(self) :
100100
places = self.v_places,
101101
msg = 'virials[%d][%d][%d] failed' % (ff,ii,jj))
102102

103-
103+
class IsPBC:
104+
def test_is_pbc(self):
105+
self.assertFalse(self.system_1.nopbc)
106+
self.assertFalse(self.system_2.nopbc)
107+
108+
class IsNoPBC:
109+
def test_is_nopbc(self):
110+
self.assertTrue(self.system_1.nopbc)
111+
self.assertTrue(self.system_2.nopbc)

tests/test_deepmd_comp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import numpy as np
33
import unittest
44
from context import dpdata
5-
from comp_sys import CompLabeledSys, CompSys
5+
from comp_sys import CompLabeledSys, CompSys, IsPBC
66

7-
class TestDeepmdLoadDumpComp(unittest.TestCase, CompLabeledSys):
7+
class TestDeepmdLoadDumpComp(unittest.TestCase, CompLabeledSys, IsPBC):
88
def setUp (self) :
99
self.system_1 = dpdata.LabeledSystem('poscars/OUTCAR.h2o.md',
1010
fmt = 'vasp/outcar')
@@ -25,7 +25,7 @@ def tearDown(self) :
2525
shutil.rmtree('tmp.deepmd.npy')
2626

2727

28-
class TestDeepmdCompNoLabels(unittest.TestCase, CompSys) :
28+
class TestDeepmdCompNoLabels(unittest.TestCase, CompSys, IsPBC) :
2929
def setUp (self) :
3030
self.system_1 = dpdata.System('poscars/POSCAR.h2o.md',
3131
fmt = 'vasp/poscar')
@@ -45,7 +45,7 @@ def tearDown(self) :
4545
shutil.rmtree('tmp.deepmd.npy')
4646

4747

48-
class TestDeepmdCompNoLabels(unittest.TestCase, CompSys) :
48+
class TestDeepmdCompNoLabels(unittest.TestCase, CompSys, IsPBC) :
4949
def setUp(self) :
5050
self.dir_name = 'tmp.deepmd.npy.nol'
5151
natoms = 3

tests/test_deepmd_raw.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import numpy as np
33
import unittest
44
from context import dpdata
5-
from comp_sys import CompLabeledSys, CompSys
5+
from comp_sys import CompLabeledSys, CompSys, IsPBC
66

7-
class TestDeepmdLoadRaw(unittest.TestCase, CompLabeledSys):
7+
class TestDeepmdLoadRaw(unittest.TestCase, CompLabeledSys, IsPBC):
88
def setUp (self) :
99
self.system_1 = dpdata.LabeledSystem('poscars/OUTCAR.h2o.md',
1010
fmt = 'vasp/outcar')
@@ -17,7 +17,7 @@ def setUp (self) :
1717
self.v_places = 6
1818

1919

20-
class TestDeepmdDumpRaw(unittest.TestCase, CompLabeledSys):
20+
class TestDeepmdDumpRaw(unittest.TestCase, CompLabeledSys, IsPBC):
2121
def setUp (self) :
2222
self.system_1 = dpdata.LabeledSystem('poscars/OUTCAR.h2o.md',
2323
fmt = 'vasp/outcar')
@@ -131,7 +131,7 @@ def test_npy_type_map_enforce (self) :
131131

132132

133133

134-
class TestDeepmdRawNoLabels(unittest.TestCase, CompSys) :
134+
class TestDeepmdRawNoLabels(unittest.TestCase, CompSys, IsPBC) :
135135
def setUp (self) :
136136
self.system_1 = dpdata.System('poscars/POSCAR.h2o.md',
137137
fmt = 'vasp/poscar')
@@ -149,7 +149,7 @@ def tearDown(self) :
149149
shutil.rmtree('tmp.deepmd')
150150

151151

152-
class TestDeepmdCompNoLabels(unittest.TestCase, CompSys) :
152+
class TestDeepmdCompNoLabels(unittest.TestCase, CompSys, IsPBC) :
153153
def setUp(self) :
154154
self.dir_name = 'tmp.deepmd.nol'
155155
natoms = 3

tests/test_gaussian_log.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import numpy as np
33
import unittest
44
from context import dpdata
5-
from comp_sys import CompLabeledSys
65

76
class TestGaussianLog :
87
def test_atom_names(self) :

tests/test_json.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import numpy as np
33
import unittest
44
from context import dpdata
5-
from comp_sys import CompLabeledSys
5+
from comp_sys import CompLabeledSys, IsNoPBC
66

7-
class TestJsonLoad(unittest.TestCase, CompLabeledSys):
7+
class TestJsonLoad(unittest.TestCase, CompLabeledSys, IsNoPBC):
88
def setUp (self) :
99
self.system_1 = dpdata.LabeledSystem('poscars/OUTCAR.h2o.md',
1010
fmt = 'vasp/outcar')
@@ -14,7 +14,7 @@ def setUp (self) :
1414
self.f_places = 6
1515
self.v_places = 4
1616

17-
class TestAsDict(unittest.TestCase, CompLabeledSys):
17+
class TestAsDict(unittest.TestCase, CompLabeledSys, IsNoPBC):
1818
def setUp (self) :
1919
self.system_1 = dpdata.LabeledSystem('poscars/OUTCAR.h2o.md',
2020
fmt = 'vasp/outcar')

tests/test_lammps_dump_skipload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import numpy as np
33
import unittest
44
from context import dpdata
5-
from comp_sys import CompSys
5+
from comp_sys import CompSys, IsNoPBC
66

7-
class TestLmpDumpSkip(unittest.TestCase, CompSys):
7+
class TestLmpDumpSkip(unittest.TestCase, CompSys, IsNoPBC):
88

99
def setUp(self):
1010
self.system_1 = dpdata.System(os.path.join('poscars', 'conf.5.dump'),

tests/test_multisystems.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from context import dpdata
55
from comp_sys import CompSys
66
from comp_sys import CompLabeledSys
7+
from comp_sys import IsNoPBC
78
from itertools import permutations
89

910
class MultiSystems:
@@ -17,7 +18,7 @@ def test_systems_size(self):
1718
def test_atom_names(self):
1819
self.assertEqual(self.atom_names, self.systems.atom_names)
1920

20-
class TestMultiSystems(unittest.TestCase, CompLabeledSys, MultiSystems):
21+
class TestMultiSystems(unittest.TestCase, CompLabeledSys, MultiSystems, IsNoPBC):
2122
def setUp(self):
2223
self.places = 6
2324
self.e_places = 6
@@ -39,7 +40,7 @@ def setUp(self):
3940
self.atom_names = ['C', 'H']
4041

4142

42-
class TestMultiSystemsAdd(unittest.TestCase, CompLabeledSys, MultiSystems):
43+
class TestMultiSystemsAdd(unittest.TestCase, CompLabeledSys, MultiSystems, IsNoPBC):
4344
def setUp(self):
4445
self.places = 6
4546
self.e_places = 6
@@ -76,7 +77,7 @@ def setUp(self):
7677
self.system_sizes = {'C1H4O0':1, 'C0H0O2':1}
7778
self.atom_names = ['C', 'H', 'O']
7879

79-
class TestMultiDeepmdDumpRaw(unittest.TestCase, CompLabeledSys):
80+
class TestMultiDeepmdDumpRaw(unittest.TestCase, CompLabeledSys, IsNoPBC):
8081
def setUp (self) :
8182
self.places = 6
8283
self.e_places = 6
@@ -94,7 +95,7 @@ def setUp (self) :
9495
self.system_1 = dpdata.LabeledSystem(os.path.join(path, 'C1H3'), fmt='deepmd/raw', type_map = ['C', 'H'])
9596
self.system_2 = system_3
9697

97-
class TestMultiDeepmdDumpComp(unittest.TestCase, CompLabeledSys):
98+
class TestMultiDeepmdDumpComp(unittest.TestCase, CompLabeledSys, IsPBC):
9899
def setUp (self) :
99100
self.places = 6
100101
self.e_places = 4

tests/test_perturb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33
import unittest
44
from context import dpdata
5-
from comp_sys import CompSys
5+
from comp_sys import CompSys, IsPBC
66

77
from unittest.mock import Mock
88
from unittest.mock import patch, MagicMock
@@ -103,7 +103,7 @@ def get_rand_generator():
103103
yield np.asarray([0.01525907, 0.68387374, 0.39768541, 0.55596047, 0.26557088, 0.60883073])
104104

105105
# %%
106-
class TestPerturbNormal(unittest.TestCase, CompSys):
106+
class TestPerturbNormal(unittest.TestCase, CompSys, IsPBC):
107107
@patch('numpy.random')
108108
def setUp (self, random_mock):
109109
random_mock.rand = NormalGenerator().rand
@@ -113,7 +113,7 @@ def setUp (self, random_mock):
113113
self.system_2 = dpdata.System('poscars/POSCAR.SiC.normal',fmt='vasp/poscar')
114114
self.places = 6
115115

116-
class TestPerturbUniform(unittest.TestCase, CompSys):
116+
class TestPerturbUniform(unittest.TestCase, CompSys, IsPBC):
117117
@patch('numpy.random')
118118
def setUp (self, random_mock) :
119119
random_mock.rand = UniformGenerator().rand
@@ -123,7 +123,7 @@ def setUp (self, random_mock) :
123123
self.system_2 = dpdata.System('poscars/POSCAR.SiC.uniform',fmt='vasp/poscar')
124124
self.places = 6
125125

126-
class TestPerturbConst(unittest.TestCase, CompSys):
126+
class TestPerturbConst(unittest.TestCase, CompSys, IsPBC):
127127
@patch('numpy.random')
128128
def setUp (self, random_mock) :
129129
random_mock.rand = ConstGenerator().rand

tests/test_qe_cp_traj_skipload.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
from context import dpdata
55
from comp_sys import CompSys
66
from comp_sys import CompLabeledSys
7+
from comp_sys import IsPBC
78

8-
class TestPWSCFTrajSkip(unittest.TestCase, CompSys):
9+
class TestPWSCFTrajSkip(unittest.TestCase, CompSys, IsPBC):
910
def setUp(self):
1011
self.system_1 = dpdata.System(os.path.join('qe.traj', 'traj6'),
1112
fmt = 'qe/cp/traj',
@@ -21,7 +22,7 @@ def setUp(self):
2122
self.f_places = 6
2223
self.v_places = 4
2324

24-
class TestPWSCFLabeledTrajSkip(unittest.TestCase, CompLabeledSys):
25+
class TestPWSCFLabeledTrajSkip(unittest.TestCase, CompLabeledSys, IsPBC):
2526
def setUp(self):
2627
self.system_1 = dpdata.LabeledSystem(os.path.join('qe.traj', 'traj6'),
2728
fmt = 'qe/cp/traj',

tests/test_quip_gap_xyz.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import numpy as np
33
import unittest
44
from context import dpdata
5-
from comp_sys import CompLabeledSys
5+
from comp_sys import CompLabeledSys, IsPBC
66

7-
class TestQuipGapxyz1(unittest.TestCase, CompLabeledSys):
7+
class TestQuipGapxyz1(unittest.TestCase, CompLabeledSys, IsPBC):
88
def setUp (self) :
99
self.multi_systems = dpdata.MultiSystems.from_file('xyz/xyz_unittest.xyz','quip/gap/xyz')
1010
self.system_1 = self.multi_systems.systems['B1C9']
@@ -14,7 +14,7 @@ def setUp (self) :
1414
self.f_places = 6
1515
self.v_places = 4
1616

17-
class TestQuipGapxyz2(unittest.TestCase, CompLabeledSys):
17+
class TestQuipGapxyz2(unittest.TestCase, CompLabeledSys, IsPBC):
1818
def setUp (self) :
1919
self.system_temp0 = dpdata.MultiSystems.from_file(file_name='xyz/xyz_unittest.xyz', fmt='quip/gap/xyz')
2020
self.system_1 = self.system_temp0.systems['B5C7'] # .sort_atom_types()
@@ -27,7 +27,7 @@ def setUp (self) :
2727
self.f_places = 6
2828
self.v_places = 4
2929

30-
class TestQuipGapxyzsort1(unittest.TestCase, CompLabeledSys):
30+
class TestQuipGapxyzsort1(unittest.TestCase, CompLabeledSys, IsPBC):
3131
def setUp (self) :
3232
self.multi_systems_1 = dpdata.MultiSystems.from_file('xyz/xyz_unittest.sort.xyz','quip/gap/xyz')
3333
self.system_1 = self.multi_systems_1.systems['B5C7']
@@ -39,7 +39,7 @@ def setUp (self) :
3939
self.f_places = 6
4040
self.v_places = 4
4141

42-
class TestQuipGapxyzsort2(unittest.TestCase, CompLabeledSys):
42+
class TestQuipGapxyzsort2(unittest.TestCase, CompLabeledSys, IsPBC):
4343
def setUp (self) :
4444
self.multi_systems_1 = dpdata.MultiSystems.from_file('xyz/xyz_unittest.sort.xyz','quip/gap/xyz')
4545
self.system_1 = self.multi_systems_1.systems['B1C9']
@@ -51,7 +51,7 @@ def setUp (self) :
5151
self.f_places = 6
5252
self.v_places = 4
5353

54-
class TestQuipGapxyzfield(unittest.TestCase, CompLabeledSys):
54+
class TestQuipGapxyzfield(unittest.TestCase, CompLabeledSys, IsPBC):
5555
def setUp (self) :
5656
self.multi_systems_1 = dpdata.MultiSystems.from_file('xyz/xyz_unittest.field.xyz','quip/gap/xyz')
5757
self.system_1 = self.multi_systems_1.systems['B1C9']
@@ -63,7 +63,7 @@ def setUp (self) :
6363
self.f_places = 6
6464
self.v_places = 4
6565

66-
class TestQuipGapxyzfield2(unittest.TestCase, CompLabeledSys):
66+
class TestQuipGapxyzfield2(unittest.TestCase, CompLabeledSys, IsPBC):
6767
def setUp (self) :
6868
self.multi_systems_1 = dpdata.MultiSystems.from_file('xyz/xyz_unittest.field.xyz','quip/gap/xyz')
6969
self.system_1 = self.multi_systems_1.systems['B5C7']

0 commit comments

Comments
 (0)