Skip to content

Commit 7adbd6a

Browse files
Fix: ignore UP031 (#1683)
1 parent fd5580e commit 7adbd6a

Some content is hidden

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

56 files changed

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

doc/conf.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 12 additions & 9 deletions
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

Lines changed: 15 additions & 10 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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 [

0 commit comments

Comments
 (0)