Skip to content
Snippets Groups Projects
Commit 300308bb authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

in hdf5 files, if one key exists, just load that

parent e8c1fcfd
No related branches found
No related tags found
1 merge request!38Deprecation
Pipeline #60559 passed
...@@ -88,12 +88,17 @@ def open_file(filename): ...@@ -88,12 +88,17 @@ def open_file(filename):
if extension in hdf5_extensions: if extension in hdf5_extensions:
with h5py.File(filename, "r") as f: with h5py.File(filename, "r") as f:
if "array" not in f.keys(): keys = list(f.keys())
if len(keys) == 1:
key = keys[0]
else:
key = "array"
if key not in keys:
raise RuntimeError( raise RuntimeError(
"The file '%s' does not contain the key 'array'" % filename f"The file {filename} does not contain the key {key}"
) )
return np.array(f["array"]) return np.array(f[key])
elif extension in image_extensions: elif extension in image_extensions:
img = imageio.imread(filename) img = imageio.imread(filename)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment