Commit 09c0819b authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[core][dataset][data] Fix errors when saving dataset with different shape from disk

parent d5dd3a11
Pipeline #53239 passed with stage
in 2 minutes and 7 seconds
......@@ -1482,8 +1482,10 @@ class Data(numpy.ndarray):
self._lock.release()
_file = h5py.File(save, 'a')
dataset_name = "dataset"
new_shape = self.shape if new_shape is None else new_shape
if "dataset" in _file:
if new_shape is not None:
if new_shape != _file["dataset"].shape:
_file.create_dataset("update_dataset", new_shape, dtype=self.dtype)
else:
_file.create_dataset("update_dataset", data=_file["dataset"])
......@@ -1545,9 +1547,11 @@ class Data(numpy.ndarray):
_file = h5py.File(path, 'a')
new_shape = self.shape if new_shape is None else new_shape
if "dataset" not in _file:
_file.create_dataset("dataset", self.shape, dtype=self.dtype)
elif new_shape is not None:
elif new_shape != _file["dataset"].shape:
del _file["dataset"]
_file.create_dataset("dataset", new_shape, dtype=self.dtype)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment