def align(str1, str2, epsilon=0):
 if (np == None):
  raise ImportError(u'You need numpy in order to use the align function')
 assert (0.0 <= epsilon <= 1.0), u'Epsilon must be between 0.0 and 1.0.'
 m = len(str1)
 n = len(str2)
 S = np.zeros(((m + 1), (n + 1)), dtype=float)
 for i in range(1, (m + 1)):
  for j in range(1, (n + 1)):
   edit1 = (S[((i - 1), j)] + sigma_skip(str1[(i - 1)]))
   edit2 = (S[(i, (j - 1))] + sigma_skip(str2[(j - 1)]))
   edit3 = (S[((i - 1), (j - 1))] + sigma_sub(str1[(i - 1)], str2[(j - 1)]))
   if (i > 1):
    edit4 = (S[((i - 2), (j - 1))] + sigma_exp(str2[(j - 1)], str1[(i - 2):i]))
   else:
    edit4 = (- inf)
   if (j > 1):
    edit5 = (S[((i - 1), (j - 2))] + sigma_exp(str1[(i - 1)], str2[(j - 2):j]))
   else:
    edit5 = (- inf)
   S[(i, j)] = max(edit1, edit2, edit3, edit4, edit5, 0)
 T = ((1 - epsilon) * np.amax(S))
 alignments = []
 for i in range(1, (m + 1)):
  for j in range(1, (n + 1)):
   if (S[(i, j)] >= T):
    alignments.append(_retrieve(i, j, 0, S, T, str1, str2, []))
 return alignments

def align ( str1 , str2 , epsilon = 0 ) : if ( np == None ) : raise ImportError ( u'You need numpy in order to use the align function' ) assert ( 0.0 <= epsilon <= 1.0 ) , u'Epsilon must be between 0.0 and 1.0.' m = len ( str1 ) n = len ( str2 ) S = np . zeros ( ( ( m + 1 ) , ( n + 1 ) ) , dtype = float ) for i in range ( 1 , ( m + 1 ) ) : for j in range ( 1 , ( n + 1 ) ) : edit1 = ( S [ ( ( i - 1 ) , j ) ] + sigma_skip ( str1 [ ( i - 1 ) ] ) ) edit2 = ( S [ ( i , ( j - 1 ) ) ] + sigma_skip ( str2 [ ( j - 1 ) ] ) ) edit3 = ( S [ ( ( i - 1 ) , ( j - 1 ) ) ] + sigma_sub ( str1 [ ( i - 1 ) ] , str2 [ ( j - 1 ) ] ) ) if ( i > 1 ) : edit4 = ( S [ ( ( i - 2 ) , ( j - 1 ) ) ] + sigma_exp ( str2 [ ( j - 1 ) ] , str1 [ ( i - 2 ) : i ] ) ) else : edit4 = ( - inf ) if ( j > 1 ) : edit5 = ( S [ ( ( i - 1 ) , ( j - 2 ) ) ] + sigma_exp ( str1 [ ( i - 1 ) ] , str2 [ ( j - 2 ) : j ] ) ) else : edit5 = ( - inf ) S [ ( i , j ) ] = max ( edit1 , edit2 , edit3 , edit4 , edit5 , 0 ) T = ( ( 1 - epsilon ) * np . amax ( S ) ) alignments = [ ] for i in range ( 1 , ( m + 1 ) ) : for j in range ( 1 , ( n + 1 ) ) : if ( S [ ( i , j ) ] >= T ) : alignments . append ( _retrieve ( i , j , 0 , S , T , str1 , str2 , [ ] ) ) return alignments
align -> int rounds x up to nearest multiple of the alignment .