Skip to content

Commit

Permalink
import h5py
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz committed May 16, 2024
1 parent 62ed77f commit facc3ee
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dpdata/plugins/deepmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ def to_system(
**kwargs : dict
other parameters
"""
import h5py

if isinstance(file_name, (h5py.Group, h5py.File)):
dpdata.deepmd.hdf5.dump(
file_name, "", data, set_size=set_size, comp_prec=comp_prec
Expand Down Expand Up @@ -332,6 +334,8 @@ def from_multi_systems(self, directory: str, **kwargs) -> h5py.Group:
h5py.Group
a HDF5 group in the HDF5 file
"""
import h5py

with h5py.File(directory, "r") as f:
for ff in f.keys():
yield f[ff]
Expand All @@ -355,6 +359,8 @@ def to_multi_systems(
h5py.Group
a HDF5 group with the name of formula
"""
import h5py

with h5py.File(directory, "w") as f:
for ff in formulas:
yield f.create_group(ff)
Expand Down

0 comments on commit facc3ee

Please sign in to comment.