Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dpdata/deepmd/mixed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import copy
import glob
import os
import shutil
Expand Down Expand Up @@ -160,6 +161,9 @@ def dump(folder, data, set_size=2000, comp_prec=np.float32, remove_sets=True):
if "real_atom_types" not in data:
from dpdata import LabeledSystem, System

# not change the original content
data = copy.deepcopy(data)

if "energies" in data:
temp_sys = LabeledSystem(data=data)
else:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_deepmd_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,27 @@ def test_str(self):
)


class TestMixedSingleSystemsDump(unittest.TestCase, CompLabeledSys, IsNoPBC):
def setUp(self):
self.places = 6
self.e_places = 6
self.f_places = 6
self.v_places = 6

# C1H4
self.system_1 = dpdata.LabeledSystem(
"gaussian/methane.gaussianlog", fmt="gaussian/log"
)
self.system_2 = dpdata.LabeledSystem(
"gaussian/methane.gaussianlog", fmt="gaussian/log"
)
# test dump
self.system_1.to("deepmd/npy/mixed", "tmp.deepmd.mixed.single")

def tearDown(self):
if os.path.exists("tmp.deepmd.mixed.single"):
shutil.rmtree("tmp.deepmd.mixed.single")


if __name__ == "__main__":
unittest.main()