Skip to content
Snippets Groups Projects
Commit da3489df authored by Guillaume CLIVAZ's avatar Guillaume CLIVAZ
Browse files

Bugfixes: gettings timestamps attributes, numpy.float deprectated and some...

Bugfixes: gettings timestamps attributes, numpy.float deprectated and some bugs due to legacy bob.io.base.HDF5File code
parent a31c8974
No related branches found
No related tags found
No related merge requests found
Pipeline #67968 failed
......@@ -757,7 +757,7 @@ class StreamView(StreamFilter):
raise ValueError(
str(view_indices)
+ " in stream with shape "
+ str(parent.shape)
+ str(self.parent.shape)
+ " results in empty stream. (shape "
+ str(self.shape)
+ ")"
......
......@@ -130,7 +130,7 @@ class StreamFile:
"""
data_config = self.get_stream_config(stream_name)
data_path = data_config["path"]
timestamps = self.hdf5_file[data_path].get("timestamps", default=None)
timestamps = self.hdf5_file[data_path].attrs.get("timestamps", default=None)
if timestamps is not None:
if isinstance(timestamps, np.ndarray) and len(timestamps) == 1 and isinstance(timestamps[0], np.bytes_):
timestamps = timestamps[0]
......@@ -179,7 +179,7 @@ class StreamFile:
unsort_index = np.argsort(index_order) # ordering that would make sorted `index` back as before sorting.
#data = np.stack([self.hdf5_file[data_path][np.array(index)[index_order]][unsort_index]])
data = self.hdf5_file[data_path][np.array(index)[index_order]][unsort_index]
if isinstance(index, int):
elif isinstance(index, int):
#data = np.stack([self.hdf5_file[data_path][index]])
data = self.hdf5_file[data_path][index]
else:
......@@ -221,7 +221,7 @@ class StreamFile:
shape = (1,) + data.shape
max_shape = (None,) + data.shape
# chunk enabled automatically with maxshape
self.hdf5_file.create_dataset(name, shape=shape, data=data, chunk=True, maxshape=max_shape)
self.hdf5_file.create_dataset(name, shape=shape, data=data, chunks=True, maxshape=max_shape)
else:
index = self.hdf5_file[name].shape[0]
self.hdf5_file[name].resize(index + 1, axis=0)
......
......@@ -35,7 +35,7 @@ def test_stream_write():
test_data = [
np.arange(5 * 3 * 40 * 52, dtype=np.int16).reshape((5, 3, 40, 52)),
np.arange(5 * 1 * 5 * 5, dtype=np.int8).reshape((5, 1, 5, 5)),
np.arange(1 * 1 * 500 * 400).astype(np.float).reshape((1, 1, 500, 400)),
np.arange(1 * 1 * 500 * 400).astype(float).reshape((1, 1, 500, 400)),
np.arange(12 * 52).astype(np.float64).reshape((12, 52)),
]
......@@ -77,8 +77,8 @@ def test_stream():
# create data file
f = h5py.File(resource_path("test/data/stream_test.h5"), "w")
f.set("data_a", data_a)
f.set("data_b", data_b)
f["data_a"] = data_a
f["data_b"] = data_b
del f
# Streams attributes when config is specified
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment