algorithms/asa.py
def _segments_are_adjacent(seg1, seg2):
    """
    Checks if seg1 and seg2 are adjacent at any point. Each is a tuple of the form
    (fidxs, sidxs).
    """
    # TODO: This is unnacceptably slow
    lsf1, lss1 = seg1
    lsf2, lss2 = seg2
    for i, f1 in enumerate(lsf1):
        for j, f2 in enumerate(lsf2):
            if f1 <= f2 + 1 and f1 >= f2 - 1:
                # Frequencies are a match, are samples?
                if lss1[i] <= lss2[j] + 1 and lss1[i] >= lss2[j] - 1:
                    return True
    return False
def _segments_are_adjacent(seg1, seg2):
    """
    Checks if seg1 and seg2 are adjacent at any point. Each is a tuple of the form
    (fidxs, sidxs).
    """
    # TODO: This is unnacceptably slow
    lsf1, lss1 = seg1
    lsf2, lss2 = seg2
    for i, f1 in enumerate(lsf1):
        for j, f2 in enumerate(lsf2):
            if f1 <= f2 + 1 and f1 >= f2 - 1:
                # Frequencies are a match, are samples?
                if lss1[i] <= lss2[j] + 1 and lss1[i] >= lss2[j] - 1:
                    return True
    return False
def _segments_are_adjacent ( seg1 , seg2 ) : # TODO: This is unnacceptably slow lsf1 , lss1 = seg1 lsf2 , lss2 = seg2 for i , f1 in enumerate ( lsf1 ) : for j , f2 in enumerate ( lsf2 ) : if f1 <= f2 + 1 and f1 >= f2 - 1 : # Frequencies are a match, are samples? if lss1 [ i ] <= lss2 [ j ] + 1 and lss1 [ i ] >= lss2 [ j ] - 1 : return True return False
Checks if seg1 and seg2 are adjacent at any point. Each is a tuple of the form
    (fidxs, sidxs).
Checks if seg1 and seg2 are adjacent at any point . Each is a tuple of the form ( fidxs sidxs ) .