@@ -47,7 +47,7 @@ def initial_restriction(self, element):
4747
4848 assert start <= end
4949 assert interval > 0
50- total_outputs = math . ceil ((end - start ) / interval )
50+ total_outputs = round ((end - start ) / interval )
5151 return OffsetRange (0 , total_outputs )
5252
5353 def create_tracker (self , restriction ):
@@ -232,10 +232,10 @@ def _validate_and_adjust_duration(self):
232232
233233 if isinstance (self .stop_ts , Timestamp ):
234234 if self .stop_ts == MAX_TIMESTAMP :
235- # adjust stop timestamp to match the data duration
236- end = start + data_duration
237- if self . interval > 1e-6 :
238- end += 1e-6
235+ # When the stop timestamp is unbounded (MAX_TIMESTAMP), set it to the
236+ # data's actual end time plus an extra fire interval, because the
237+ # impulse duration's upper bound is exclusive.
238+ end = start + data_duration + self . interval
239239 self .stop_ts = Timestamp .of (end )
240240 else :
241241 end = self .stop_ts .micros / 1000000
@@ -244,7 +244,7 @@ def _validate_and_adjust_duration(self):
244244
245245 # The total time for the impulse signal which occurs in [start, end).
246246 impulse_duration = end - start
247- if data_duration + self .interval < impulse_duration :
247+ if round ( data_duration + self .interval , 6 ) < round ( impulse_duration , 6 ) :
248248 # We don't have enough data for the impulse.
249249 # If we can fit at least one more data point in the impulse duration,
250250 # then we will be in the repeat mode.
@@ -264,8 +264,8 @@ def _validate_and_adjust_duration(self):
264264
265265 def __init__ (
266266 self ,
267- start_timestamp : Union [ Timestamp , float ] = Timestamp .now (),
268- stop_timestamp : Union [ Timestamp , float ] = MAX_TIMESTAMP ,
267+ start_timestamp : Timestamp = Timestamp .now (),
268+ stop_timestamp : Timestamp = MAX_TIMESTAMP ,
269269 fire_interval : float = 360.0 ,
270270 apply_windowing : bool = False ,
271271 data : Optional [Sequence [Any ]] = None ):
0 commit comments