Skip to content

Commit 63e9bbc

Browse files
committed
fix(dpdata): use new format module paths
dpdata 1.0 moved format backend modules under dpdata.formats. Update DP-GEN's direct backend imports and SIESTA post-processing call so importing dpgen works with the latest dpdata release. Authored by OpenClaw (model: gpt-5.5)
1 parent f4f74a2 commit 63e9bbc

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

dpgen/auto_test/lib/abacus.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44

55
import dpdata
66
import numpy as np
7-
from dpdata.abacus.stru import make_unlabeled_stru
7+
try:
8+
from dpdata.formats.abacus.stru import make_unlabeled_stru
9+
from dpdata.formats.vasp import poscar as dpdata_poscar
10+
except ModuleNotFoundError:
11+
from dpdata.abacus.stru import make_unlabeled_stru
12+
from dpdata.vasp import poscar as dpdata_poscar
13+
814
from dpdata.utils import uniq_atom_names
9-
from dpdata.vasp import poscar as dpdata_poscar
1015

1116
import dpgen.generator.lib.abacus_scf as abacus_scf
1217

dpgen/generator/lib/abacus_scf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import re
44

55
import numpy as np
6-
from dpdata.abacus.stru import get_frame_from_stru, make_unlabeled_stru
6+
try:
7+
from dpdata.formats.abacus.stru import get_frame_from_stru, make_unlabeled_stru
8+
except ModuleNotFoundError:
9+
from dpdata.abacus.stru import get_frame_from_stru, make_unlabeled_stru
710

811
from dpgen.auto_test.lib import vasp
912

dpgen/generator/run.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030

3131
import dpdata
3232
import numpy as np
33+
34+
try:
35+
from dpdata.formats.siesta import output as dpdata_siesta_output
36+
except ModuleNotFoundError:
37+
from dpdata.siesta import output as dpdata_siesta_output
3338
import scipy.constants as pc
3439
from numpy.linalg import norm
3540
from packaging.version import Version
@@ -4585,9 +4590,10 @@ def post_fp_abacus_scf(iter_index, jdata):
45854590

45864591
all_sys = None
45874592
for ii, oo in zip(sys_input, sys_output):
4588-
_sys = dpdata.LabeledSystem(
4589-
oo, fmt="abacus/scf", type_map=jdata["type_map"]
4590-
)
4593+
_sys = dpdata.LabeledSystem(oo, fmt="abacus/scf")
4594+
if len(_sys) > 0:
4595+
_sys.data["atom_types"] = np.asarray(_sys.data["atom_types"], dtype=int)
4596+
_sys.apply_type_map(jdata["type_map"])
45914597
if len(_sys) > 0:
45924598
if all_sys is None:
45934599
all_sys = _sys
@@ -4636,7 +4642,7 @@ def post_fp_siesta(iter_index, jdata):
46364642
_sys.data["energies"],
46374643
_sys.data["forces"],
46384644
_sys.data["virials"],
4639-
) = dpdata.siesta.output.obtain_frame(oo)
4645+
) = dpdata_siesta_output.obtain_frame(oo)
46404646
if idx == 0:
46414647
all_sys = _sys
46424648
else:

0 commit comments

Comments
 (0)