@@ -459,6 +459,47 @@ def test_player_annotations(raw_annotations, close_io, chunk_size, request):
459
459
player .stop ()
460
460
461
461
462
+ @pytest .mark .slow
463
+ def test_player_annotations_no_duration (raw_annotations , close_io , chunk_size , request ):
464
+ """Test player with annotations."""
465
+ name = f"P_{ request .node .name } "
466
+ source_id = uuid .uuid4 ().hex
467
+ annotations = sorted (set (raw_annotations .annotations .description ))
468
+ raw_annotations .annotations .duration .fill (0 ) # overwrite durations
469
+ player = Player (
470
+ raw_annotations , chunk_size = chunk_size , name = name , source_id = source_id
471
+ )
472
+ assert f"Player: { name } " in repr (player )
473
+ assert player .name == name
474
+ assert player .source_id == source_id
475
+ assert player .fname == Path (raw_annotations .filenames [0 ])
476
+ streams = resolve_streams (timeout = 0.1 )
477
+ assert (name , source_id ) not in [
478
+ (stream .name , stream .source_id ) for stream in streams
479
+ ]
480
+ player .start ()
481
+ streams = resolve_streams (timeout = 2 )
482
+ assert (name , source_id ) in [(stream .name , stream .source_id ) for stream in streams ]
483
+ assert (f"{ name } -annotations" , source_id ) in [
484
+ (stream .name , stream .source_id ) for stream in streams
485
+ ]
486
+ # compare with a Stream object for simplicity
487
+ stream = Stream (bufsize = 40 , stype = "annotations" , source_id = source_id )
488
+ stream .connect (processing_flags = ["clocksync" ])
489
+ assert stream .info ["ch_names" ] == annotations
490
+ time .sleep (3 ) # acquire some annotations
491
+ for picks in ("bad_test" , "test2" , "test3" ):
492
+ data , ts = stream .get_data (picks = picks )
493
+ data = data .squeeze ()
494
+ assert ts .size == data .size
495
+ idx = np .where (data != 0.0 )[0 ]
496
+ assert_allclose (data [idx ], [- 1 ] * idx .size )
497
+ # clean-up
498
+ stream .disconnect ()
499
+ close_io ()
500
+ player .stop ()
501
+
502
+
462
503
@pytest .fixture
463
504
def raw_annotations_1000_samples () -> BaseRaw :
464
505
"""Return a 1000 sample raw object with annotations."""
0 commit comments