@@ -31,6 +31,7 @@ def test_sync_empty_stream(n_clock_offsets, handle_clock_resets):
31
31
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
32
32
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
33
33
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
34
+ np .testing .assert_equal (streams [1 ].clock_segments , [])
34
35
35
36
36
37
@pytest .mark .parametrize ("n_time_stamps" , list (range (0 , 5 )))
@@ -55,6 +56,7 @@ def test_sync_empty_offsets(n_time_stamps, handle_clock_resets):
55
56
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
56
57
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
57
58
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
59
+ np .testing .assert_equal (streams [1 ].clock_segments , [])
58
60
59
61
60
62
@pytest .mark .parametrize ("n_clock_offsets" , list (range (2 , 5 )))
@@ -87,6 +89,7 @@ def test_sync_no_resets(n_clock_offsets, clock_value, handle_clock_resets):
87
89
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
88
90
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
89
91
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
92
+ np .testing .assert_equal (streams [1 ].clock_segments , [(0 , len (time_stamps ) - 1 )])
90
93
91
94
92
95
@pytest .mark .parametrize ("n_clock_offsets" , list (range (2 , 4 )))
@@ -119,6 +122,7 @@ def test_sync_no_resets_bounds(n_clock_offsets, clock_value, handle_clock_resets
119
122
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
120
123
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
121
124
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
125
+ np .testing .assert_equal (streams [1 ].clock_segments , [(0 , len (time_stamps ) - 1 )])
122
126
123
127
124
128
@pytest .mark .parametrize ("n_clock_offsets" , list (range (2 , 4 )))
@@ -165,6 +169,7 @@ def test_sync_no_resets_bounds_jitter(
165
169
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
166
170
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
167
171
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
172
+ np .testing .assert_equal (streams [1 ].clock_segments , [(0 , len (time_stamps ) - 1 )])
168
173
169
174
170
175
# Clock resets.
@@ -191,6 +196,13 @@ def test_sync_clock_jumps_forward_break_at_reset():
191
196
expected ,
192
197
atol = 1e-13 ,
193
198
)
199
+ np .testing .assert_equal (
200
+ streams [1 ].clock_segments ,
201
+ [
202
+ (0 , 4 ),
203
+ (5 , 9 ),
204
+ ],
205
+ )
194
206
195
207
196
208
def test_sync_clock_jumps_forward_break_between_reset ():
@@ -214,6 +226,13 @@ def test_sync_clock_jumps_forward_break_between_reset():
214
226
expected ,
215
227
atol = 1e-13 ,
216
228
)
229
+ np .testing .assert_equal (
230
+ streams [1 ].clock_segments ,
231
+ [
232
+ (0 , 7 ),
233
+ (8 , 15 ),
234
+ ],
235
+ )
217
236
218
237
219
238
def test_sync_clock_jumps_backward_break_at_reset ():
@@ -237,6 +256,13 @@ def test_sync_clock_jumps_backward_break_at_reset():
237
256
expected ,
238
257
atol = 1e-13 ,
239
258
)
259
+ np .testing .assert_equal (
260
+ streams [1 ].clock_segments ,
261
+ [
262
+ (0 , 4 ),
263
+ (5 , 9 ),
264
+ ],
265
+ )
240
266
241
267
242
268
def test_sync_clock_jumps_backward_break_between_reset ():
@@ -260,6 +286,13 @@ def test_sync_clock_jumps_backward_break_between_reset():
260
286
expected ,
261
287
atol = 1e-13 ,
262
288
)
289
+ np .testing .assert_equal (
290
+ streams [1 ].clock_segments ,
291
+ [
292
+ (0 , 7 ),
293
+ (8 , 15 ),
294
+ ],
295
+ )
263
296
264
297
265
298
@pytest .mark .parametrize (
@@ -296,9 +329,16 @@ def test_sync_clock_jumps_forward_tdiffs(clock_offsets, tdiff, clock_tdiff):
296
329
time_stamps = np .hstack (
297
330
[np .arange (start , stop , tdiff ) for start , stop in clock_reset_times ]
298
331
)
299
- expected = np .hstack (
300
- [np .arange (0 , clock_tdiff * offsets , tdiff ) for offsets in offsets_per_range ]
301
- )
332
+ expected = [
333
+ np .arange (0 , clock_tdiff * offsets , tdiff ) for offsets in offsets_per_range
334
+ ]
335
+ expected_clock_segments = []
336
+ seg_start_idx = 0
337
+ for segment in expected :
338
+ seg_end_idx = seg_start_idx + len (segment ) - 1
339
+ expected_clock_segments .append ((seg_start_idx , seg_end_idx ))
340
+ seg_start_idx = seg_end_idx + 1
341
+ expected = np .hstack (expected )
302
342
streams = {
303
343
1 : MockStreamData (
304
344
time_stamps = time_stamps ,
@@ -318,6 +358,7 @@ def test_sync_clock_jumps_forward_tdiffs(clock_offsets, tdiff, clock_tdiff):
318
358
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
319
359
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
320
360
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
361
+ np .testing .assert_equal (streams [1 ].clock_segments , expected_clock_segments )
321
362
322
363
323
364
@pytest .mark .parametrize (
@@ -354,9 +395,16 @@ def test_sync_clock_jumps_backward_tdiffs(clock_offsets, tdiff, clock_tdiff):
354
395
time_stamps = np .hstack (
355
396
[np .arange (start , stop , tdiff ) for start , stop in clock_reset_times ]
356
397
)
357
- expected = np .hstack (
358
- [np .arange (0 , clock_tdiff * offsets , tdiff ) for offsets in offsets_per_range ]
359
- )
398
+ expected = [
399
+ np .arange (0 , clock_tdiff * offsets , tdiff ) for offsets in offsets_per_range
400
+ ]
401
+ expected_clock_segments = []
402
+ seg_start_idx = 0
403
+ for segment in expected :
404
+ seg_end_idx = seg_start_idx + len (segment ) - 1
405
+ expected_clock_segments .append ((seg_start_idx , seg_end_idx ))
406
+ seg_start_idx = seg_end_idx + 1
407
+ expected = np .hstack (expected )
360
408
streams = {
361
409
1 : MockStreamData (
362
410
time_stamps = time_stamps ,
@@ -375,6 +423,7 @@ def test_sync_clock_jumps_backward_tdiffs(clock_offsets, tdiff, clock_tdiff):
375
423
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
376
424
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
377
425
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
426
+ np .testing .assert_equal (streams [1 ].clock_segments , expected_clock_segments )
378
427
379
428
380
429
@pytest .mark .parametrize (
@@ -411,9 +460,16 @@ def test_sync_clock_jumps_forward_backward_tdiffs(clock_offsets, tdiff, clock_td
411
460
time_stamps = np .hstack (
412
461
[np .arange (start , stop , tdiff ) for start , stop in clock_reset_times ]
413
462
)
414
- expected = np .hstack (
415
- [np .arange (0 , clock_tdiff * offsets , tdiff ) for offsets in offsets_per_range ]
416
- )
463
+ expected = [
464
+ np .arange (0 , clock_tdiff * offsets , tdiff ) for offsets in offsets_per_range
465
+ ]
466
+ expected_clock_segments = []
467
+ seg_start_idx = 0
468
+ for segment in expected :
469
+ seg_end_idx = seg_start_idx + len (segment ) - 1
470
+ expected_clock_segments .append ((seg_start_idx , seg_end_idx ))
471
+ seg_start_idx = seg_end_idx + 1
472
+ expected = np .hstack (expected )
417
473
streams = {
418
474
1 : MockStreamData (
419
475
time_stamps = time_stamps ,
@@ -433,3 +489,4 @@ def test_sync_clock_jumps_forward_backward_tdiffs(clock_offsets, tdiff, clock_td
433
489
np .testing .assert_equal (streams [1 ].time_series [:, 0 ], time_stamps )
434
490
np .testing .assert_equal (streams [1 ].clock_times , clock_times )
435
491
np .testing .assert_equal (streams [1 ].clock_values , clock_values )
492
+ np .testing .assert_equal (streams [1 ].clock_segments , expected_clock_segments )
0 commit comments