-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support collecting MultiSystems (#1422)
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d90939c
commit c3d8f96
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import json | ||
import tempfile | ||
import unittest | ||
from pathlib import Path | ||
|
||
import dpdata | ||
|
||
from dpgen.collect.collect import collect_data | ||
|
||
|
||
class TestCollectData(unittest.TestCase): | ||
def setUp(self): | ||
self.data = dpdata.LabeledSystem( | ||
Path(__file__).parent / "generator" / "data" / "deepmd", fmt="deepmd/npy" | ||
) | ||
|
||
def test_collect_data(self): | ||
with tempfile.TemporaryDirectory() as inpdir, tempfile.TemporaryDirectory() as outdir, tempfile.NamedTemporaryFile() as param_file: | ||
self.data.to_deepmd_npy(Path(inpdir) / "iter.000000" / "02.fp" / "data.000") | ||
self.data.to_deepmd_npy( | ||
Path(inpdir) / "iter.000001" / "02.fp" / "data.000" / "aa" | ||
) | ||
self.data.to_deepmd_npy( | ||
Path(inpdir) / "iter.000001" / "02.fp" / "data.000" / "bb" | ||
) | ||
with open(param_file.name, "w") as fp: | ||
json.dump( | ||
{"sys_configs": ["sys1"], "model_devi_jobs": [{}, {}, {}]}, fp | ||
) | ||
|
||
collect_data(inpdir, param_file.name, outdir, verbose=True) | ||
ms = dpdata.MultiSystems().from_deepmd_npy(outdir) | ||
self.assertEqual(ms.get_nframes(), self.data.get_nframes() * 3) |