Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 4, 2024
1 parent d91e2ed commit b697ac0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dpgen/auto_test/Gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def _compute_lower(self, output_file, all_tasks, all_res):
miller_index = loadfn(os.path.join(ii, "miller.json"))
ptr_data += (
"%-25s %7.2f %7.3f %8.3f %8.3f\n" # noqa: UP031
% (
% (
str(miller_index) + "-" + structure_dir + ":",
int(ii[-4:]) / self.n_steps,
sfe,
Expand Down
27 changes: 20 additions & 7 deletions tests/generator/test_make_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,15 @@ def _make_fake_md(idx, md_descript, atom_types, type_map, ele_temp=None):
sys.data["coords"] = coords
sys.data["cells"] = cells
task_dir = os.path.join(
"iter.%06d" % idx, "01.model_devi", "task.%03d.%06d" % (sidx, midx) # noqa: UP031 # noqa: UP031
"iter.%06d" % idx,
"01.model_devi",
"task.%03d.%06d" % (sidx, midx), # noqa: UP031 # noqa: UP031
)
os.makedirs(os.path.join(task_dir, "traj"), exist_ok=True)
for ii in range(nframes):
_write_lammps_dump(
sys, os.path.join(task_dir, "traj", "%d.lammpstrj" % ii) # noqa: UP031
sys,
os.path.join(task_dir, "traj", "%d.lammpstrj" % ii), # noqa: UP031
)
md_out = np.zeros([nframes, 7])
md_out[:, 0] = np.arange(nframes)
Expand Down Expand Up @@ -301,7 +304,9 @@ def _make_fake_md_merge_traj(idx, md_descript, atom_types, type_map, ele_temp=No
sys.data["coords"] = coords
sys.data["cells"] = cells
task_dir = os.path.join(
"iter.%06d" % idx, "01.model_devi", "task.%03d.%06d" % (sidx, midx) # noqa: UP031 # noqa: UP031
"iter.%06d" % idx,
"01.model_devi",
"task.%03d.%06d" % (sidx, midx), # noqa: UP031 # noqa: UP031
)
cwd = os.getcwd()
os.makedirs(task_dir, exist_ok=True)
Expand Down Expand Up @@ -344,7 +349,9 @@ def _check_poscars(testCase, idx, fp_task_max, type_map):
for tt, ff in zip(md_task, f_idx):
traj_file = os.path.join(tt, "traj", "%d.lammpstrj" % int(ff)) # noqa: UP031
poscar_file = os.path.join(
fp_path, "task.%03d.%06d" % (int(sidx), cc), "POSCAR" # noqa: UP031
fp_path,
"task.%03d.%06d" % (int(sidx), cc),
"POSCAR", # noqa: UP031
)
cc += 1
sys0 = dpdata.System(traj_file, fmt="lammps/dump", type_map=type_map)
Expand Down Expand Up @@ -373,7 +380,9 @@ def _check_poscars_merge_traj(testCase, idx, fp_task_max, type_map):
for tt, ff in zip(md_task, f_idx):
traj_file = os.path.join(tt, "all.lammpstrj")
poscar_file = os.path.join(
fp_path, "task.%03d.%06d" % (int(sidx), cc), "POSCAR" # noqa: UP031
fp_path,
"task.%03d.%06d" % (int(sidx), cc),
"POSCAR", # noqa: UP031
)
cc += 1
sys0 = dpdata.System(traj_file, fmt="lammps/dump", type_map=type_map)
Expand Down Expand Up @@ -840,7 +849,9 @@ def test_make_fp_amber_diff(self):
jdata = json.load(fp)
jdata["mdin_prefix"] = os.path.abspath(jdata["mdin_prefix"])
task_dir = os.path.join(
"iter.%06d" % 0, "01.model_devi", "task.%03d.%06d" % (0, 0) # noqa: UP031 # noqa: UP031
"iter.%06d" % 0,
"01.model_devi",
"task.%03d.%06d" % (0, 0), # noqa: UP031 # noqa: UP031
)
os.makedirs(task_dir, exist_ok=True)
with open(os.path.join(task_dir, "rc.mdout"), "w") as f:
Expand Down Expand Up @@ -1369,7 +1380,9 @@ def test_make_fp_custom(self):
for cc, (tt, ff) in enumerate(zip(md_task, f_idx)):
traj_file = os.path.join(tt, "traj", "%d.lammpstrj" % int(ff)) # noqa: UP031
input_file = os.path.join(
fp_path, "task.%03d.%06d" % (int(sidx), cc), input_fn # noqa: UP031
fp_path,
"task.%03d.%06d" % (int(sidx), cc),
input_fn, # noqa: UP031
)
system1 = dpdata.System(traj_file, "lammps/dump", type_map=type_map)
system2 = dpdata.System(input_file, input_fmt, type_map=type_map)
Expand Down
13 changes: 10 additions & 3 deletions tests/generator/test_make_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def _make_fake_models(idx, numb_models):
fp.write(str(ii))
if not os.path.isfile("graph.%03d.pb" % ii): # noqa: UP031
os.symlink(
os.path.join("%03d" % ii, "forzen_model.pb"), "graph.%03d.pb" % ii # noqa: UP031 # noqa: UP031
os.path.join("%03d" % ii, "forzen_model.pb"),
"graph.%03d.pb" % ii, # noqa: UP031 # noqa: UP031
)
os.chdir(pwd)

Expand Down Expand Up @@ -697,7 +698,10 @@ def test_restart_from_iter(self):
restart_text = "This is the fake restart file to test `restart_from_iter`"
with open(
os.path.join(
"iter.%06d" % 0, "01.model_devi", "task.000.000000", "rc.rst7" # noqa: UP031
"iter.%06d" % 0,
"01.model_devi",
"task.000.000000",
"rc.rst7", # noqa: UP031
),
"w",
) as fw:
Expand All @@ -708,7 +712,10 @@ def test_restart_from_iter(self):
self._check_input(1)
with open(
os.path.join(
"iter.%06d" % 1, "01.model_devi", "task.000.000000", "init.rst7" # noqa: UP031
"iter.%06d" % 1,
"01.model_devi",
"task.000.000000",
"init.rst7", # noqa: UP031
)
) as f:
assert f.read() == restart_text
Expand Down
16 changes: 13 additions & 3 deletions tests/generator/test_make_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ def _check_model_inputs_v1(testCase, iter_idx, jdata, reuse=False):
def _make_fake_fp(iter_idx, sys_idx, nframes):
for ii in range(nframes):
dirname = os.path.join(
"iter.%06d" % iter_idx, "02.fp", "task.%03d.%06d" % (sys_idx, ii) # noqa: UP031 # noqa: UP031
"iter.%06d" % iter_idx,
"02.fp",
"task.%03d.%06d" % (sys_idx, ii), # noqa: UP031 # noqa: UP031
)
os.makedirs(dirname, exist_ok=True)
dirname = os.path.join("iter.%06d" % iter_idx, "02.fp", "data.%03d" % sys_idx) # noqa: UP031 # noqa: UP031
Expand Down Expand Up @@ -543,7 +545,11 @@ def test_training_finetune_model(self):
self.assertTrue(
os.path.isfile(
os.path.join(
"iter.000000", "00.train", "%03d" % ii, "old", "init.pb" # noqa: UP031
"iter.000000",
"00.train",
"%03d" % ii,
"old",
"init.pb", # noqa: UP031
)
)
)
Expand Down Expand Up @@ -594,7 +600,11 @@ def test_training_init_frozen_model(self):
self.assertTrue(
os.path.isfile(
os.path.join(
"iter.000000", "00.train", "%03d" % ii, "old", "init.pb" # noqa: UP031
"iter.000000",
"00.train",
"%03d" % ii,
"old",
"init.pb", # noqa: UP031
)
)
)
Expand Down

0 comments on commit b697ac0

Please sign in to comment.