#NEWLINE# def peek( self , dag ) : #NEWLINE# #INDENT# " Infer which internal events are/aren't going to occur (for the entire\n    sequence of input events in dag)" #NEWLINE# if ( len ( dag . input_events ) == 0 ) : #NEWLINE# #INDENT# return dag #NEWLINE# #UNINDENT# if ( not isinstance ( dag . events [ 0 ] , ConnectToControllers ) ) : #NEWLINE# #INDENT# raise ValueError ( 'First event must be ConnectToControllers' ) #NEWLINE# #UNINDENT# assert ( dag . input_events [ 0 ] != dag . events [ 0 ] ) #NEWLINE# input_events = ( [ dag . events [ 0 ] ] + dag . input_events ) #NEWLINE# current_input_prefix = list ( self . _prefix_trie . longest_prefix ( input_events , default = [ ] ) ) #NEWLINE# log . debug ( ( 'Current input prefix: %s' % str ( current_input_prefix ) ) ) #NEWLINE# inferred_events = list ( self . _prefix_trie . longest_prefix_value ( input_events , default = [ ] ) ) #NEWLINE# log . debug ( ( 'Current inferred_events: %s' % str ( inferred_events ) ) ) #NEWLINE# inject_input_idx = len ( current_input_prefix ) #NEWLINE# while ( inject_input_idx < len ( input_events ) ) : #NEWLINE# #INDENT# inject_input = input_events [ inject_input_idx ] #NEWLINE# following_input = get_following_input ( inject_input_idx , inferred_events . input_events ) #NEWLINE# log . debug ( ( "peek()'ing after input %d" % inject_input_idx ) ) #NEWLINE# expected_internal_events = get_expected_internal_events ( inject_input , following_input , dag . events ) #NEWLINE# if ( expected_internal_events == [ ] ) : #NEWLINE# #INDENT# log . debug ( 'Optimization: no expected internal events' ) #NEWLINE# newly_inferred_events = [ ] #NEWLINE# Peeker . ambiguous_counts [ 0.0 ] += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# wait_time_seconds = self . get_wait_time_seconds ( inject_input , following_input ) #NEWLINE# fencepost = NOPInput ( time = inject_input . time , round = inject_input . round ) #NEWLINE# replay_dag = EventDag ( ( inferred_events + [ fencepost ] ) ) #NEWLINE# found_events = self . find_internal_events ( replay_dag , inject_input , wait_time_seconds ) #NEWLINE# newly_inferred_events = match_and_filter ( found_events , expected_internal_events ) #NEWLINE# #UNINDENT# ( current_input_prefix , inferred_events ) = self . _update_trie ( current_input_prefix , inject_input , inferred_events , newly_inferred_events ) #NEWLINE# inject_input_idx += 1 #NEWLINE# #UNINDENT# return EventDag ( inferred_events )