MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / read_hdf5

Function read_hdf5

modules/parallel_wavegan/utils/utils.py:39–63  ·  view source on GitHub ↗

Read hdf5 dataset. Args: hdf5_name (str): Filename of hdf5 file. hdf5_path (str): Dataset name in hdf5 file. Return: any: Dataset values.

(hdf5_name, hdf5_path)

Source from the content-addressed store, hash-verified

37
38
39def read_hdf5(hdf5_name, hdf5_path):
40 """Read hdf5 dataset.
41
42 Args:
43 hdf5_name (str): Filename of hdf5 file.
44 hdf5_path (str): Dataset name in hdf5 file.
45
46 Return:
47 any: Dataset values.
48
49 """
50 if not os.path.exists(hdf5_name):
51 logging.error(f"There is no such a hdf5 file ({hdf5_name}).")
52 sys.exit(1)
53
54 hdf5_file = h5py.File(hdf5_name, "r")
55
56 if hdf5_path not in hdf5_file:
57 logging.error(f"There is no such a data in hdf5 file. ({hdf5_path})")
58 sys.exit(1)
59
60 hdf5_data = hdf5_file[hdf5_path][()]
61 hdf5_file.close()
62
63 return hdf5_data
64
65
66def write_hdf5(hdf5_name, hdf5_path, write_data, is_overwrite=True):

Callers 2

load_pwg_modelFunction · 0.90
__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected