Skip to content

Commit d5cc8f8

Browse files
Merge branch 'devel' into fix-simplify-pt
2 parents d22f754 + 3a1ed00 commit d5cc8f8

21 files changed

+100
-40
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828

2929
# Python
3030
- repo: https://github.com/astral-sh/ruff-pre-commit
31-
rev: v0.5.1
31+
rev: v0.5.2
3232
hooks:
3333
- id: ruff
3434
args: ["--fix"]

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ sphinx>=4.0.2,!=7.2.5
33
recommonmark
44
sphinx_rtd_theme
55
sphinx_markdown_tables
6-
sphinx-argparse
6+
sphinx-argparse<0.5.0
77
myst-parser
88
deepmodeling_sphinx>=0.1.1
99
dargs>=0.3.1

dpgen/auto_test/Elastic.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
from shutil import copyfile
55

66
from monty.serialization import dumpfn, loadfn
7-
from pymatgen.analysis.elasticity.elastic import ElasticTensor
8-
from pymatgen.analysis.elasticity.strain import DeformedStructureSet, Strain
9-
from pymatgen.analysis.elasticity.stress import Stress
10-
from pymatgen.core.structure import Structure
11-
from pymatgen.io.vasp import Incar, Kpoints
127

138
import dpgen.auto_test.lib.abacus as abacus
149
import dpgen.auto_test.lib.vasp as vasp
@@ -53,6 +48,9 @@ def __init__(self, parameter, inter_param=None):
5348
self.inter_param = inter_param if inter_param is not None else {"type": "vasp"}
5449

5550
def make_confs(self, path_to_work, path_to_equi, refine=False):
51+
from pymatgen.analysis.elasticity.strain import DeformedStructureSet, Strain
52+
from pymatgen.core.structure import Structure
53+
5654
path_to_work = os.path.abspath(path_to_work)
5755
if os.path.exists(path_to_work):
5856
dlog.warning(f"{path_to_work} already exists")
@@ -189,6 +187,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
189187
return task_list
190188

191189
def post_process(self, task_list):
190+
from pymatgen.io.vasp import Incar, Kpoints
191+
192192
if self.inter_param["type"] == "abacus":
193193
POSCAR = "STRU"
194194
INCAR = "INPUT"
@@ -250,6 +250,9 @@ def task_param(self):
250250
return self.parameter
251251

252252
def _compute_lower(self, output_file, all_tasks, all_res):
253+
from pymatgen.analysis.elasticity.elastic import ElasticTensor
254+
from pymatgen.analysis.elasticity.stress import Stress
255+
253256
output_file = os.path.abspath(output_file)
254257
res_data = {}
255258
ptr_data = os.path.dirname(output_file) + "\n"

dpgen/auto_test/Gamma.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from ase.lattice.cubic import BodyCenteredCubic as bcc
99
from ase.lattice.cubic import FaceCenteredCubic as fcc
1010
from monty.serialization import dumpfn, loadfn
11-
from pymatgen.core.structure import Structure
12-
from pymatgen.io.ase import AseAtomsAdaptor
1311

1412
import dpgen.auto_test.lib.abacus as abacus
1513
import dpgen.auto_test.lib.vasp as vasp
@@ -94,6 +92,8 @@ def __init__(self, parameter, inter_param=None):
9492
self.inter_param = inter_param if inter_param is not None else {"type": "vasp"}
9593

9694
def make_confs(self, path_to_work, path_to_equi, refine=False):
95+
from pymatgen.core.structure import Structure
96+
9797
path_to_work = os.path.abspath(path_to_work)
9898
if os.path.exists(path_to_work):
9999
dlog.warning(f"{path_to_work} already exists")
@@ -287,6 +287,8 @@ def return_direction(self):
287287
return directions
288288

289289
def __gen_slab_ase(self, symbol, lat_param):
290+
from pymatgen.io.ase import AseAtomsAdaptor
291+
290292
if not self.lattice_type:
291293
raise RuntimeError("Error! Please provide the input lattice type!")
292294
elif self.lattice_type == "bcc":

dpgen/auto_test/Interstitial.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import numpy as np
77
from monty.serialization import dumpfn, loadfn
8-
from pymatgen.analysis.defects.generators import InterstitialGenerator
9-
from pymatgen.core.structure import Structure
108

119
import dpgen.auto_test.lib.abacus as abacus
1210
import dpgen.auto_test.lib.lammps as lammps
@@ -78,6 +76,9 @@ def __init__(self, parameter, inter_param=None):
7876
self.inter_param = inter_param if inter_param is not None else {"type": "vasp"}
7977

8078
def make_confs(self, path_to_work, path_to_equi, refine=False):
79+
from pymatgen.analysis.defects.generators import InterstitialGenerator
80+
from pymatgen.core.structure import Structure
81+
8182
path_to_work = os.path.abspath(path_to_work)
8283
path_to_equi = os.path.abspath(path_to_equi)
8384

dpgen/auto_test/Surface.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import dpdata
77
import numpy as np
88
from monty.serialization import dumpfn, loadfn
9-
from pymatgen.core.structure import Structure
10-
from pymatgen.core.surface import generate_all_slabs
119

1210
import dpgen.auto_test.lib.abacus as abacus
1311
import dpgen.auto_test.lib.vasp as vasp
@@ -85,6 +83,9 @@ def __init__(self, parameter, inter_param=None):
8583
self.inter_param = inter_param if inter_param is not None else {"type": "vasp"}
8684

8785
def make_confs(self, path_to_work, path_to_equi, refine=False):
86+
from pymatgen.core.structure import Structure
87+
from pymatgen.core.surface import generate_all_slabs
88+
8889
path_to_work = os.path.abspath(path_to_work)
8990
if os.path.exists(path_to_work):
9091
dlog.warning(f"{path_to_work} already exists")

dpgen/auto_test/VASP.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from dpdata import LabeledSystem
44
from monty.serialization import dumpfn
5-
from pymatgen.core.structure import Structure
6-
from pymatgen.io.vasp import Incar, Kpoints
75

86
import dpgen.auto_test.lib.vasp as vasp
97
from dpgen import dlog
@@ -22,6 +20,8 @@ def __init__(self, inter_parameter, path_to_poscar):
2220
self.path_to_poscar = path_to_poscar
2321

2422
def make_potential_files(self, output_dir):
23+
from pymatgen.core.structure import Structure
24+
2525
potcar_not_link_list = ["vacancy", "interstitial"]
2626
task_type = output_dir.split("/")[-2].split("_")[0]
2727

@@ -69,6 +69,8 @@ def make_potential_files(self, output_dir):
6969
dumpfn(self.inter, os.path.join(output_dir, "inter.json"), indent=4)
7070

7171
def make_input_file(self, output_dir, task_type, task_param):
72+
from pymatgen.io.vasp import Incar, Kpoints
73+
7274
sepline(ch=output_dir)
7375
dumpfn(task_param, os.path.join(output_dir, "task.json"), indent=4)
7476

dpgen/auto_test/Vacancy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import numpy as np
77
from monty.serialization import dumpfn, loadfn
8-
from pymatgen.analysis.defects.generators import VacancyGenerator
9-
from pymatgen.core.structure import Structure
108

119
import dpgen.auto_test.lib.abacus as abacus
1210
from dpgen import dlog
@@ -77,6 +75,9 @@ def __init__(self, parameter, inter_param=None):
7775
self.inter_param = inter_param if inter_param is not None else {"type": "vasp"}
7876

7977
def make_confs(self, path_to_work, path_to_equi, refine=False):
78+
from pymatgen.analysis.defects.generators import VacancyGenerator
79+
from pymatgen.core.structure import Structure
80+
8081
path_to_work = os.path.abspath(path_to_work)
8182
if os.path.exists(path_to_work):
8283
dlog.warning(f"{path_to_work} already exists")

dpgen/auto_test/gen_confs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import os
55
import re
66

7-
from pymatgen.analysis.structure_matcher import StructureMatcher
8-
from pymatgen.ext.matproj import MPRester
9-
107
import dpgen.auto_test.lib.crys as crys
118

129
global_std_crystal = {
@@ -20,6 +17,8 @@
2017

2118

2219
def test_fit(struct, data):
20+
from pymatgen.analysis.structure_matcher import StructureMatcher
21+
2322
m = StructureMatcher()
2423
for ii in data:
2524
if m.fit(ii["structure"], struct):
@@ -50,6 +49,9 @@ def gen_ele_std(ele_name, ctype):
5049

5150

5251
def gen_element(ele_name, key):
52+
from pymatgen.analysis.structure_matcher import StructureMatcher
53+
from pymatgen.ext.matproj import MPRester
54+
5355
assert isinstance(ele_name, str)
5456
mpr = MPRester(key)
5557
data = mpr.query(
@@ -93,6 +95,8 @@ def gen_element_std(ele_name):
9395

9496

9597
def gen_alloy(eles, key):
98+
from pymatgen.ext.matproj import MPRester
99+
96100
mpr = MPRester(key)
97101

98102
data = mpr.query(

dpgen/auto_test/lib/abacus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from dpdata.abacus.scf import make_unlabeled_stru
88
from dpdata.utils import uniq_atom_names
99
from dpdata.vasp import poscar as dpdata_poscar
10-
from pymatgen.core.structure import Structure
1110

1211
import dpgen.generator.lib.abacus_scf as abacus_scf
1312

@@ -343,6 +342,8 @@ def final_stru(abacus_path):
343342

344343

345344
def stru2Structure(struf):
345+
from pymatgen.core.structure import Structure
346+
346347
stru = dpdata.System(struf, fmt="stru")
347348
stru.to("poscar", "POSCAR.tmp")
348349
ss = Structure.from_file("POSCAR.tmp")

0 commit comments

Comments
 (0)