Skip to content

Commit

Permalink
fix a bug in convert_training_data_to_hdf5 (#1167)
Browse files Browse the repository at this point in the history
In this method, `p2` has been started with `/` so no `/` should be added
again.
  • Loading branch information
njzjz authored Mar 25, 2023
1 parent 43f0ca9 commit 9ea063c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dpgen/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def convert_training_data_to_hdf5(input_files: List[str], h5_file: str):
p1, p2 = pp.split("#")
ff = os.path.normpath(str((dd / p1).absolute().relative_to(cwd)))
pp = ff + "#" + p2
new_pp = os.path.normpath(os.path.relpath(ff, h5_dir)) + "/" + p2
new_pp = os.path.normpath(os.path.relpath(ff, h5_dir)) + p2
else:
pp = os.path.normpath(str((dd / pp).absolute().relative_to(cwd)))
new_pp = os.path.normpath(os.path.relpath(pp, h5_dir))
Expand All @@ -144,7 +144,7 @@ def convert_training_data_to_hdf5(input_files: List[str], h5_file: str):
if "#" in ii:
p1, p2 = ii.split("#")
p1 = os.path.normpath(os.path.relpath(p1, h5_dir))
group = f.create_group(str(p1) + "/" + p2)
group = f.create_group(str(p1) + p2)
s = dpdata.LabeledSystem(ii, fmt="deepmd/hdf5")
s.to("deepmd/hdf5", group)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/generator/test_make_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def test_1_data_v1_one_h5(self):
jdata0["training"]["systems"],
[
"../data.hdf5#/data.init/deepmd",
"../data.hdf5#/data.init/deepmd.hdf5/",
"../data.hdf5#/data.init/deepmd.hdf5",
"../data.hdf5#/data.iters/iter.000000/02.fp/data.000",
],
)
Expand Down

0 comments on commit 9ea063c

Please sign in to comment.