Commit 48b7b75f authored by Vincent POLLET's avatar Vincent POLLET

Test for timestamps writing

parent ec188036
Pipeline #54324 failed with stage
in 120 minutes and 10 seconds
......@@ -38,19 +38,30 @@ def test_stream_write():
np.arange(12 * 52).astype(np.float64).reshape((12, 52)),
]
for a_test_data in test_data:
test_timestamps = [
np.linspace(0, 20*test_data[0].shape[0], test_data[0].shape[0]),
np.linspace(10, 10*test_data[1].shape[0], test_data[1].shape[0]),
np.linspace(100, 200*test_data[2].shape[0], test_data[2].shape[0]),
np.linspace(5, 6*test_data[3].shape[0], test_data[3].shape[0]),
]
for a_test_data, a_test_timestamps in zip(test_data, test_timestamps):
with StreamFile(resource_path("test/data/save_test.h5"), mode="w") as output_file:
stream = Stream("test_data")
save_filter = stream.save(output_file)
for i in range(a_test_data.shape[0]):
stream.put(a_test_data[i])
stream.put(a_test_data[i], a_test_timestamps[i])
with StreamFile(resource_path("test/data/save_test.h5"), mode="r") as input_file:
stream = Stream("test_data", input_file)
data = stream.load()
timestamps = input_file.get_stream_timestamps("test_data")
if np.isscalar(timestamps): # if there is only 1 frame, timestamps are returned as a scalar
timestamps = np.array([timestamps])
assert np.array_equal(data, a_test_data)
assert data.dtype == a_test_data.dtype
assert np.array_equal(timestamps, a_test_timestamps)
os.remove(resource_path("test/data/save_test.h5"))
......
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