Skip to content

Commit

Permalink
fix timing test
Browse files Browse the repository at this point in the history
  • Loading branch information
timonmerk authored and toni-neurosc committed Sep 19, 2024
1 parent 37ea063 commit d0538c4
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions tests/test_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ def test_setting_computation_time():
)

# test if features up till the last sample was computed
assert (
data_duration_s * 1000 - features.time.iloc[-1]
) < 1000 / sampling_rate_features_hz
assert features.time.iloc[-1] == data_duration_s * fs


# test that the time difference between two samples is the feature sampling rate
assert (
features.time.iloc[1] - features.time.iloc[0]
) == 1000 / sampling_rate_features_hz
) == fs / sampling_rate_features_hz

assert features.time.iloc[0] == settings.segment_length_features_ms - 1
assert features.time.iloc[0] == settings.segment_length_features_ms


def test_float_fs():
Expand All @@ -65,16 +64,10 @@ def test_float_fs():

features = stream.run(out_dir="./test_data", experiment_name="test_float_fs")

# test if features up till the last sample was computed
assert (
data_duration_s * 1000 - features.time.iloc[-1]
) < 1000 / sampling_rate_features_hz

# test that the time difference between two samples is the feature sampling rate
assert (
features.time.iloc[1] - features.time.iloc[0]
) == 1000 / sampling_rate_features_hz

# TONI: I fixed this test so that it passes, but I feel it's not the right way to test timestamp correctness
# test that the first feature segment timestamp matches settings.segment_length_features_ms
assert features["time"].iloc[0] == settings.segment_length_features_ms - 1
# the timing of the first sample cannot be directly inferred from the segment length
# the samples are computed based on rounding to full indices of the original data

0 comments on commit d0538c4

Please sign in to comment.