@@ -579,26 +579,53 @@ def test_tagged_range_dim(self):
579
579
# +0.1 should round up (ceil) the start position
580
580
# +0.1 * 2 should round down (floor) the stop position and works the same for both inclusive and
581
581
# exclusive
582
- tag .position = [pos + 0.1 ]
583
- tag .extent = [ext + 0.1 ]
584
- start = pos + 1
585
- stop = pos + ext + 1
582
+ tag .position = [pos + 0.1 ]
583
+ tag .extent = [ext + 0.1 ]
584
+ start = pos + 1
585
+ stop = pos + ext + 1
586
586
np .testing .assert_array_almost_equal (tag .tagged_data (0 ), da [start :stop ])
587
587
np .testing .assert_array_almost_equal (tag .tagged_data (0 , nix .SliceMode .Exclusive ), da [start :stop ])
588
588
np .testing .assert_array_almost_equal (tag .tagged_data (0 , nix .SliceMode .Inclusive ), da [start :stop ])
589
589
590
- if pos + ext + 2 < len (da ):
590
+ if pos + ext + 2 < len (da ):
591
591
# +0.9 should round up (ceil) the start position
592
592
# +0.9 * 2 should round down (floor) the stop position and works the same for both inclusive and
593
593
# exclusive
594
- tag .position = [pos + 0.9 ]
595
- tag .extent = [ext + 0.9 ]
596
- start = pos + 1
597
- stop = pos + ext + 2
594
+ tag .position = [pos + 0.9 ]
595
+ tag .extent = [ext + 0.9 ]
596
+ start = pos + 1
597
+ stop = pos + ext + 2
598
598
np .testing .assert_array_almost_equal (tag .tagged_data (0 ), da [start :stop ])
599
599
np .testing .assert_array_almost_equal (tag .tagged_data (0 , nix .SliceMode .Exclusive ), da [start :stop ])
600
600
np .testing .assert_array_almost_equal (tag .tagged_data (0 , nix .SliceMode .Inclusive ), da [start :stop ])
601
601
602
+ time_vector = np .arange (0.0 , 10. , 0.001 )
603
+ indices = np .random .rand (len (time_vector ))
604
+ event_data = time_vector [(indices < 0.1 )]
605
+ event_data = event_data [(event_data < 4 ) | (event_data > 7 )]
606
+
607
+ event_da = self .block .create_data_array ("event_data" , "nix.events" , data = event_data , unit = "s" )
608
+ event_da .append_range_dimension_using_self ()
609
+ selection = event_da .get_slice ([4.5 ], [1.0 ], nix .DataSliceMode .Data )[:]
610
+
611
+ tt = self .block .create_tag ("no_event_segment" , "nix.segment" , 4.5 )
612
+ tt .extent = 1.0
613
+ tt .references .append (event_da )
614
+ slice = tt .tagged_data (0 )
615
+ self .assertFalse (slice .valid )
616
+
617
+ tt2 = self .block .create_tag ("beyond data" , "nix.segment" , 12.0 )
618
+ tt2 .extent = 3.0
619
+ tt2 .references .append (event_da )
620
+ slice = tt2 .tagged_data (0 )
621
+ self .assertFalse (slice .valid )
622
+
623
+ tt3 = self .block .create_tag ("reachingbeyonddata" , "nix.segment" , 8.5 )
624
+ tt3 .extent = [3.0 ]
625
+ tt3 .references .append (event_da )
626
+ slice = tt3 .tagged_data (0 )
627
+ self .assertTrue (slice .valid )
628
+
602
629
def test_tagged_sampled_dim (self ):
603
630
"""
604
631
Simple test where the slice can be calculated directly from the position and extent and compared to the original
0 commit comments