def findAcceptablePatterns(tp, t, whichSequence, trainingSequences, nAcceptable=1):
 upTo = (t + 2)
 if tp.doPooling:
  upTo += min(tp.segUpdateValidDuration, nAcceptable)
 assert (upTo <= len(trainingSequences[whichSequence]))
 acceptablePatterns = []
 if ((len(trainingSequences) == 2) and (trainingSequences[0][0] == trainingSequences[1][0]).all()):
  if ((trainingSequences[0][t] == trainingSequences[1][t]).all() and (trainingSequences[0][(t + 1)] != trainingSequences[1][(t + 1)]).any()):
   acceptablePatterns.append(trainingSequences[0][(t + 1)])
   acceptablePatterns.append(trainingSequences[1][(t + 1)])
 acceptablePatterns += [trainingSequences[whichSequence][t] for t in xrange(t, upTo)]
 return acceptablePatterns

def findAcceptablePatterns ( tp , t , whichSequence , trainingSequences , nAcceptable = 1 ) : upTo = ( t + 2 ) if tp . doPooling : upTo += min ( tp . segUpdateValidDuration , nAcceptable ) assert ( upTo <= len ( trainingSequences [ whichSequence ] ) ) acceptablePatterns = [ ] if ( ( len ( trainingSequences ) == 2 ) and ( trainingSequences [ 0 ] [ 0 ] == trainingSequences [ 1 ] [ 0 ] ) . all ( ) ) : if ( ( trainingSequences [ 0 ] [ t ] == trainingSequences [ 1 ] [ t ] ) . all ( ) and ( trainingSequences [ 0 ] [ ( t + 1 ) ] != trainingSequences [ 1 ] [ ( t + 1 ) ] ) . any ( ) ) : acceptablePatterns . append ( trainingSequences [ 0 ] [ ( t + 1 ) ] ) acceptablePatterns . append ( trainingSequences [ 1 ] [ ( t + 1 ) ] ) acceptablePatterns += [ trainingSequences [ whichSequence ] [ t ] for t in xrange ( t , upTo ) ] return acceptablePatterns
tries to infer the set of acceptable patterns for prediction at the given time step and for the give sequence .