Skip to content

Commit 9b5fab4

Browse files
authored
merge devel to master to release v0.13.1 (#1721)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores / Style Enhancements** - Improved internal code quality by standardizing style and suppressing routine linting warnings. - **Dependency Update** - Upgraded a key dependency to ensure better performance and future compatibility. - **Compatibility Improvements** - Expanded support for newer external toolkit versions, enhancing overall stability. - **Test & Documentation Refinements** - Made minor adjustments in tests and documentation strings to improve clarity without affecting functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents e02e6a2 + bc70e21 commit 9b5fab4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+645
-699
lines changed

.pre-commit-config.yaml

+1-1
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.7.4
31+
rev: v0.9.6
3232
hooks:
3333
- id: ruff
3434
args: ["--fix"]

doc/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# -- Project information -----------------------------------------------------
2020

2121
project = "DP-GEN"
22-
copyright = "2020-%d, DeepModeling" % date.today().year
22+
copyright = "2020-%d, DeepModeling" % date.today().year # noqa: UP031
2323
author = "DeepModeling"
2424

2525

dpgen/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ def info():
4848
]:
4949
try:
5050
mm = __import__(modui)
51-
print("%10s %10s %s" % (modui, mm.__version__, mm.__path__[0]))
51+
print("%10s %10s %s" % (modui, mm.__version__, mm.__path__[0])) # noqa: UP031
5252
except ImportError:
53-
print("%10s %10s Not Found" % (modui, ""))
53+
print("%10s %10s Not Found" % (modui, "")) # noqa: UP031
5454
except AttributeError:
55-
print("%10s %10s unknown version or path" % (modui, ""))
55+
print("%10s %10s unknown version or path" % (modui, "")) # noqa: UP031
5656
print()
5757

5858
# reference

dpgen/auto_test/EOS.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
198198
# vol = vol / 100.0
199199
vol = self.vol_start + task_num * self.vol_step
200200
# task_num = int((vol - self.vol_start) / self.vol_step)
201-
output_task = os.path.join(path_to_work, "task.%06d" % task_num)
201+
output_task = os.path.join(path_to_work, "task.%06d" % task_num) # noqa: UP031
202202
os.makedirs(output_task, exist_ok=True)
203203
os.chdir(output_task)
204204
if self.inter_param["type"] == "abacus":

dpgen/auto_test/Elastic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
162162
print("gen with norm " + str(norm_strains))
163163
print("gen with shear " + str(shear_strains))
164164
for ii in range(n_dfm):
165-
output_task = os.path.join(path_to_work, "task.%06d" % ii)
165+
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
166166
os.makedirs(output_task, exist_ok=True)
167167
os.chdir(output_task)
168168
for jj in [

dpgen/auto_test/Gamma.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
223223
os.symlink(os.path.relpath(equi_contcar), POSCAR)
224224
# task_poscar = os.path.join(output, 'POSCAR')
225225
for ii in range(len(all_slabs)):
226-
output_task = os.path.join(path_to_work, "task.%06d" % ii)
226+
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
227227
os.makedirs(output_task, exist_ok=True)
228228
os.chdir(output_task)
229229
for jj in ["INCAR", "POTCAR", POSCAR, "conf.lmp", "in.lammps"]:
@@ -232,9 +232,9 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
232232
task_list.append(output_task)
233233
# print("# %03d generate " % ii, output_task)
234234
print(
235-
"# %03d generate " % ii,
235+
"# %03d generate " % ii, # noqa: UP031
236236
output_task,
237-
" \t %d atoms" % self.atom_num,
237+
" \t %d atoms" % self.atom_num, # noqa: UP031
238238
)
239239
# make confs
240240
all_slabs[ii].to("POSCAR.tmp", "POSCAR")
@@ -472,12 +472,15 @@ def _compute_lower(self, output_file, all_tasks, all_res):
472472
)
473473

474474
miller_index = loadfn(os.path.join(ii, "miller.json"))
475-
ptr_data += "%-25s %7.2f %7.3f %8.3f %8.3f\n" % (
476-
str(miller_index) + "-" + structure_dir + ":",
477-
int(ii[-4:]) / self.n_steps,
478-
sfe,
479-
epa,
480-
equi_epa_slab,
475+
ptr_data += (
476+
"%-25s %7.2f %7.3f %8.3f %8.3f\n" # noqa: UP031
477+
% (
478+
str(miller_index) + "-" + structure_dir + ":",
479+
int(ii[-4:]) / self.n_steps,
480+
sfe,
481+
epa,
482+
equi_epa_slab,
483+
)
481484
)
482485
res_data[int(ii[-4:]) / self.n_steps] = [sfe, epa, equi_epa]
483486

dpgen/auto_test/Interstitial.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
222222
# task_poscar = os.path.join(output, 'POSCAR')
223223

224224
for ii in range(len(dss)):
225-
output_task = os.path.join(path_to_work, "task.%06d" % ii)
225+
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
226226
os.makedirs(output_task, exist_ok=True)
227227
os.chdir(output_task)
228228
for jj in [
@@ -262,7 +262,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
262262

263263
super_latt_param = float(pos_line[2].split()[0])
264264

265-
output_task1 = os.path.join(path_to_work, "task.%06d" % (len(dss)))
265+
output_task1 = os.path.join(path_to_work, "task.%06d" % (len(dss))) # noqa: UP031
266266
os.makedirs(output_task1, exist_ok=True)
267267
os.chdir(output_task1)
268268
task_list.append(output_task1)
@@ -283,7 +283,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
283283
os.chdir(cwd)
284284

285285
output_task2 = os.path.join(
286-
path_to_work, "task.%06d" % (len(dss) + 1)
286+
path_to_work,
287+
"task.%06d" % (len(dss) + 1), # noqa: UP031
287288
)
288289
os.makedirs(output_task2, exist_ok=True)
289290
os.chdir(output_task2)
@@ -305,7 +306,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
305306
os.chdir(cwd)
306307

307308
output_task3 = os.path.join(
308-
path_to_work, "task.%06d" % (len(dss) + 2)
309+
path_to_work,
310+
"task.%06d" % (len(dss) + 2), # noqa: UP031
309311
)
310312
os.makedirs(output_task3, exist_ok=True)
311313
os.chdir(output_task3)
@@ -346,7 +348,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
346348
replace_label = idx
347349

348350
output_task4 = os.path.join(
349-
path_to_work, "task.%06d" % (len(dss) + 3)
351+
path_to_work,
352+
"task.%06d" % (len(dss) + 3), # noqa: UP031
350353
)
351354
os.makedirs(output_task4, exist_ok=True)
352355
os.chdir(output_task4)
@@ -380,7 +383,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
380383
os.chdir(cwd)
381384

382385
output_task5 = os.path.join(
383-
path_to_work, "task.%06d" % (len(dss) + 4)
386+
path_to_work,
387+
"task.%06d" % (len(dss) + 4), # noqa: UP031
384388
)
385389
os.makedirs(output_task5, exist_ok=True)
386390
os.chdir(output_task5)
@@ -414,7 +418,8 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
414418
os.chdir(cwd)
415419

416420
output_task6 = os.path.join(
417-
path_to_work, "task.%06d" % (len(dss) + 5)
421+
path_to_work,
422+
"task.%06d" % (len(dss) + 5), # noqa: UP031
418423
)
419424
os.makedirs(output_task6, exist_ok=True)
420425
os.chdir(output_task6)
@@ -453,7 +458,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
453458

454459
if self.inter_param["type"] == "abacus":
455460
for ii in range(total_task):
456-
output_task = os.path.join(path_to_work, "task.%06d" % ii)
461+
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
457462
os.chdir(output_task)
458463
abacus.poscar2stru("POSCAR", self.inter_param, "STRU")
459464
os.remove("POSCAR")
@@ -478,8 +483,8 @@ def post_process(self, task_list):
478483
type_num = type_map[insert_ele] + 1
479484
conf_line[2] = str(len(type_map_list)) + " atom types"
480485
conf_line[-2] = (
481-
"%6.d" % int(insert_line.split()[0])
482-
+ "%7.d" % type_num
486+
"%6.d" % int(insert_line.split()[0]) # noqa: UP031
487+
+ "%7.d" % type_num # noqa: UP031
483488
+ f"{float(insert_line.split()[2]):16.10f}"
484489
+ f"{float(insert_line.split()[3]):16.10f}"
485490
+ f"{float(insert_line.split()[4]):16.10f}"

dpgen/auto_test/Surface.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
198198
os.symlink(os.path.relpath(equi_contcar), POSCAR)
199199
# task_poscar = os.path.join(output, 'POSCAR')
200200
for ii in range(len(all_slabs)):
201-
output_task = os.path.join(path_to_work, "task.%06d" % ii)
201+
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
202202
os.makedirs(output_task, exist_ok=True)
203203
os.chdir(output_task)
204204
for jj in [
@@ -213,9 +213,9 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
213213
os.remove(jj)
214214
task_list.append(output_task)
215215
print(
216-
"# %03d generate " % ii,
216+
"# %03d generate " % ii, # noqa: UP031
217217
output_task,
218-
" \t %d atoms" % len(all_slabs[ii].sites),
218+
" \t %d atoms" % len(all_slabs[ii].sites), # noqa: UP031
219219
)
220220
# make confs
221221
all_slabs[ii].to("POSCAR.tmp", "POSCAR")
@@ -270,7 +270,7 @@ def _compute_lower(self, output_file, all_tasks, all_res):
270270
evac = (task_result["energies"][-1] - equi_epa * natoms) / AA * Cf
271271

272272
miller_index = loadfn(os.path.join(ii, "miller.json"))
273-
ptr_data += "%-25s %7.3f %8.3f %8.3f\n" % (
273+
ptr_data += "%-25s %7.3f %8.3f %8.3f\n" % ( # noqa: UP031
274274
str(miller_index) + "-" + structure_dir + ":",
275275
evac,
276276
epa,

dpgen/auto_test/VASP.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def make_input_file(self, output_dir, task_type, task_param):
112112
isif = 2
113113
if not ("NSW" in incar and incar.get("NSW") == nsw):
114114
dlog.info(
115-
"%s setting NSW to %d"
115+
"%s setting NSW to %d" # noqa: UP031
116116
% (self.make_input_file.__name__, nsw)
117117
)
118118
incar["NSW"] = nsw
@@ -121,15 +121,15 @@ def make_input_file(self, output_dir, task_type, task_param):
121121

122122
if not ("ISIF" in incar and incar.get("ISIF") == isif):
123123
dlog.info(
124-
"%s setting ISIF to %d" % (self.make_input_file.__name__, isif)
124+
"%s setting ISIF to %d" % (self.make_input_file.__name__, isif) # noqa: UP031
125125
)
126126
incar["ISIF"] = isif
127127

128128
elif cal_type == "static":
129129
nsw = 0
130130
if not ("NSW" in incar and incar.get("NSW") == nsw):
131131
dlog.info(
132-
"%s setting NSW to %d" % (self.make_input_file.__name__, nsw)
132+
"%s setting NSW to %d" % (self.make_input_file.__name__, nsw) # noqa: UP031
133133
)
134134
incar["NSW"] = nsw
135135

dpgen/auto_test/Vacancy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
187187
# task_poscar = os.path.join(output, 'POSCAR')
188188

189189
for ii in range(len(dss)):
190-
output_task = os.path.join(path_to_work, "task.%06d" % ii)
190+
output_task = os.path.join(path_to_work, "task.%06d" % ii) # noqa: UP031
191191
os.makedirs(output_task, exist_ok=True)
192192
os.chdir(output_task)
193193
for jj in [

dpgen/auto_test/common_prop.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def run_property(confs, inter_param, property_list, mdata):
102102
# conf_dirs.sort()
103103
processes = len(property_list)
104104
pool = Pool(processes=processes)
105-
print("Submit job via %d processes" % processes)
105+
print("Submit job via %d processes" % processes) # noqa: UP031
106106
conf_dirs = []
107107
for conf in confs:
108108
conf_dirs.extend(glob.glob(conf))
@@ -181,8 +181,8 @@ def run_property(confs, inter_param, property_list, mdata):
181181
for ii in range(len(multiple_ret)):
182182
if not multiple_ret[ii].successful():
183183
print("ERROR:", multiple_ret[ii].get())
184-
raise RuntimeError("Job %d is not successful!" % ii)
185-
print("%d jobs are finished" % len(multiple_ret))
184+
raise RuntimeError("Job %d is not successful!" % ii) # noqa: UP031
185+
print("%d jobs are finished" % len(multiple_ret)) # noqa: UP031
186186

187187

188188
def worker(

dpgen/auto_test/lib/abacus.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import dpdata
66
import numpy as np
7-
from dpdata.abacus.scf import make_unlabeled_stru
7+
from dpdata.abacus.stru import make_unlabeled_stru
88
from dpdata.utils import uniq_atom_names
99
from dpdata.vasp import poscar as dpdata_poscar
1010

@@ -161,25 +161,25 @@ def poscar2stru(poscar, inter_param, stru="STRU"):
161161
else:
162162
atom_mass_dict = inter_param["atom_masses"]
163163
for atom in stru_data["atom_names"]:
164-
assert (
165-
atom in atom_mass_dict
166-
), f"the mass of {atom} is not defined in interaction:atom_masses"
164+
assert atom in atom_mass_dict, (
165+
f"the mass of {atom} is not defined in interaction:atom_masses"
166+
)
167167
atom_mass.append(atom_mass_dict[atom])
168168

169169
if "potcars" in inter_param:
170170
pseudo = []
171171
for atom in stru_data["atom_names"]:
172-
assert (
173-
atom in inter_param["potcars"]
174-
), f"the pseudopotential of {atom} is not defined in interaction:potcars"
172+
assert atom in inter_param["potcars"], (
173+
f"the pseudopotential of {atom} is not defined in interaction:potcars"
174+
)
175175
pseudo.append("./pp_orb/" + inter_param["potcars"][atom].split("/")[-1])
176176

177177
if "orb_files" in inter_param:
178178
orb = []
179179
for atom in stru_data["atom_names"]:
180-
assert (
181-
atom in inter_param["orb_files"]
182-
), f"orbital file of {atom} is not defined in interaction:orb_files"
180+
assert atom in inter_param["orb_files"], (
181+
f"orbital file of {atom} is not defined in interaction:orb_files"
182+
)
183183
orb.append("./pp_orb/" + inter_param["orb_files"][atom].split("/")[-1])
184184

185185
if "deepks_desc" in inter_param:
@@ -333,7 +333,7 @@ def final_stru(abacus_path):
333333
if lines[-i][1:27] == "STEP OF MOLECULAR DYNAMICS":
334334
max_step = int(lines[-i].split()[-1])
335335
break
336-
return "OUT.%s/STRU_MD_%d" % (suffix, max_step)
336+
return "OUT.%s/STRU_MD_%d" % (suffix, max_step) # noqa: UP031
337337
elif calculation == "scf":
338338
return "STRU"
339339
else:

0 commit comments

Comments
 (0)