Skip to content

Commit 2482d02

Browse files
committed
fix: update helper imports after format move
1 parent 8393ecf commit 2482d02

9 files changed

Lines changed: 46 additions & 28 deletions

File tree

dpdata/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
from __future__ import annotations
22

33
from .bond_order_system import BondOrderSystem
4-
from .formats import lammps, md, vasp
54
from .system import LabeledSystem, MultiSystems, System
65

76
try:
87
from ._version import version as __version__
98
except ImportError:
109
from .__about__ import __version__
1110

11+
1212
__all__ = [
1313
"__version__",
14-
"lammps",
15-
"md",
16-
"vasp",
1714
"System",
1815
"LabeledSystem",
1916
"MultiSystems",

dpdata/formats/cp2k/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from . import cell, output
4+
5+
__all__ = ["cell", "output"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from . import fchk, gjf, log
4+
5+
__all__ = ["fchk", "gjf", "log"]

dpdata/formats/qe/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from . import scf, traj
4+
5+
__all__ = ["scf", "traj"]

tests/test_cell_to_low_triangle.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import unittest
44

55
import numpy as np
6-
from context import dpdata
6+
7+
from dpdata.formats.cp2k.cell import cell_to_low_triangle
78

89

910
class TestCellToLowTriangle(unittest.TestCase):
1011
def test_func1(self):
11-
cell_1 = dpdata.cp2k.cell.cell_to_low_triangle(
12+
cell_1 = cell_to_low_triangle(
1213
6, 6, 6, np.pi * 1 / 2, np.pi * 1 / 2, np.pi * 1 / 2
1314
)
1415
cell_2 = np.asarray([[6, 0, 0], [0, 6, 0], [0, 0, 6]])
@@ -17,7 +18,7 @@ def test_func1(self):
1718
self.assertAlmostEqual(cell_1[ii, jj], cell_2[ii, jj], places=6)
1819

1920
def test_func2(self):
20-
cell_1 = dpdata.cp2k.cell.cell_to_low_triangle(
21+
cell_1 = cell_to_low_triangle(
2122
6, 6, 6, np.pi * 1 / 3, np.pi * 1 / 3, np.pi * 1 / 3
2223
)
2324
cell_2 = np.asarray(
@@ -28,7 +29,7 @@ def test_func2(self):
2829
self.assertAlmostEqual(cell_1[ii, jj], cell_2[ii, jj], places=6)
2930

3031
def test_func3(self):
31-
cell_1 = dpdata.cp2k.cell.cell_to_low_triangle(
32+
cell_1 = cell_to_low_triangle(
3233
6, 7, 8, np.pi * 133 / 180, np.pi * 84 / 180, np.pi * 69 / 180
3334
)
3435
cell_2 = np.asarray(
@@ -45,21 +46,17 @@ def test_func3(self):
4546

4647
def test_func4(self):
4748
with self.assertRaises(Exception) as c:
48-
dpdata.cp2k.cell.cell_to_low_triangle(
49-
0.1, 6, 6, np.pi * 1 / 2, np.pi * 1 / 2, np.pi * 1 / 2
50-
)
49+
cell_to_low_triangle(0.1, 6, 6, np.pi * 1 / 2, np.pi * 1 / 2, np.pi * 1 / 2)
5150
self.assertTrue("A==0.1" in str(c.exception))
5251

5352
def test_func5(self):
5453
with self.assertRaises(Exception) as c:
55-
dpdata.cp2k.cell.cell_to_low_triangle(
56-
6, 6, 6, np.pi * 3 / 180, np.pi * 1 / 2, np.pi * 1 / 2
57-
)
54+
cell_to_low_triangle(6, 6, 6, np.pi * 3 / 180, np.pi * 1 / 2, np.pi * 1 / 2)
5855
self.assertTrue("alpha" in str(c.exception))
5956

6057
def test_func6(self):
6158
with self.assertRaises(Exception) as c:
62-
dpdata.cp2k.cell.cell_to_low_triangle(
59+
cell_to_low_triangle(
6360
6, 7, 8, np.pi * 153 / 180, np.pi * 84 / 180, np.pi * 69 / 180
6461
)
6562
self.assertTrue("lz^2" in str(c.exception))

tests/test_gaussian_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from comp_sys import CompSys, IsNoPBC
1010
from context import dpdata
1111

12+
from dpdata.formats.gaussian.gjf import detect_multiplicity
13+
1214

1315
@unittest.skipIf(shutil.which("g16") is None, "g16 is not installed")
1416
@unittest.skipIf(
@@ -83,9 +85,7 @@ def test_detect_multiplicity(self):
8385
self._check_multiplicity(["C", "H"], 2)
8486

8587
def _check_multiplicity(self, symbols, multiplicity):
86-
self.assertEqual(
87-
dpdata.gaussian.gjf.detect_multiplicity(np.array(symbols)), multiplicity
88-
)
88+
self.assertEqual(detect_multiplicity(np.array(symbols)), multiplicity)
8989

9090
def tearDown(self):
9191
if os.path.exists("gaussian/tmp.gjf"):

tests/test_msd.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import numpy as np
66
from context import dpdata
77

8+
from dpdata.formats.md.msd import msd as calc_msd
9+
810

911
class TestMSD(unittest.TestCase):
1012
def setUp(self):
@@ -22,9 +24,9 @@ def setUp(self):
2224

2325
def test_msd(self):
2426
# print(self.system['atom_types'] == 0)
25-
msd = dpdata.md.msd.msd(self.system)
26-
msd0 = dpdata.md.msd.msd(self.system, self.system["atom_types"] == 0)
27-
msd1 = dpdata.md.msd.msd(self.system, self.system["atom_types"] == 1)
27+
msd = calc_msd(self.system)
28+
msd0 = calc_msd(self.system, self.system["atom_types"] == 0)
29+
msd1 = calc_msd(self.system, self.system["atom_types"] == 1)
2830
# print(msd)
2931
ncomp = msd.shape[0]
3032
for ii in range(ncomp):

tests/test_qe_cp_traj.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import numpy as np
66
from context import dpdata
77

8+
from dpdata.formats.qe.traj import convert_celldm
9+
810
bohr2ang = dpdata.unit.LengthConversion("bohr", "angstrom").value()
911

1012

@@ -61,7 +63,7 @@ def setUp(self):
6163

6264
class TestConverCellDim(unittest.TestCase):
6365
def test_case_null(self):
64-
cell = dpdata.qe.traj.convert_celldm(8, [1, 1, 1])
66+
cell = convert_celldm(8, [1, 1, 1])
6567
ref = np.eye(3)
6668
for ii in range(3):
6769
for jj in range(3):

tests/test_water_ions.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
from context import dpdata
77

8+
from dpdata.formats.md.water import (
9+
compute_bonds,
10+
compute_bonds_ase,
11+
compute_bonds_naive,
12+
find_ions,
13+
)
14+
815
try:
916
import ase # noqa: F401
1017
import ase.neighborlist # noqa: F401
@@ -20,16 +27,14 @@ def setUp(self):
2027
self.system.from_lammps_lmp(
2128
os.path.join("poscars", "conf.waterion.lmp"), type_map=["O", "H"]
2229
)
23-
self.bonds = dpdata.md.water.compute_bonds(
30+
self.bonds = compute_bonds(
2431
self.system.data["cells"][0],
2532
self.system.data["coords"][0],
2633
self.system.data["atom_types"],
2734
)
2835

2936
def test_ions_count(self):
30-
no, noh, noh2, noh3, nh = dpdata.md.water.find_ions(
31-
self.system.data["atom_types"], self.bonds
32-
)
37+
no, noh, noh2, noh3, nh = find_ions(self.system.data["atom_types"], self.bonds)
3338
self.assertEqual(len(no), 0)
3439
self.assertEqual(len(noh), 1)
3540
self.assertEqual(len(noh2), 125)
@@ -46,12 +51,12 @@ def setUp(self):
4651
self.system.from_lammps_lmp(
4752
os.path.join("poscars", "conf.waterion.lmp"), type_map=["O", "H"]
4853
)
49-
self.bonds = dpdata.md.water.compute_bonds_naive(
54+
self.bonds = compute_bonds_naive(
5055
self.system.data["cells"][0],
5156
self.system.data["coords"][0],
5257
self.system.data["atom_types"],
5358
)
54-
self.bonds_ase = dpdata.md.water.compute_bonds_ase(
59+
self.bonds_ase = compute_bonds_ase(
5560
self.system.data["cells"][0],
5661
self.system.data["coords"][0],
5762
self.system.data["atom_types"],

0 commit comments

Comments
 (0)