match_quality should be a value between 0 and 1.
194861
def add(self, domain_accession, domain_type, match_quality):
        ''''''
        self.matches[domain_type] = self.matches.get(domain_type, {})
        self.matches[domain_type][domain_accession] = match_quality
644316
private static boolean matches(String matchHeader, String toMatch) {
        String[] matchValues = matchHeader.split("\\s*,\\s*");
        Arrays.sort(matchValues);
        return Arrays.binarySearch(matchValues, toMatch) > -1
                || Arrays.binarySearch(matchValues, "*") > -1;
    }
902787
def get_below_threshold(umi_quals, quality_encoding,  quality_filter_threshold):
    ''''''
    umi_quals = [x - RANGES[quality_encoding][0] for x in map(ord, umi_quals)]
    below_threshold = [x < quality_filter_threshold for x in umi_quals]
    return below_threshold
577482
def is_exact(needle, haystack, start, end, matchnot):
    """"""
    return ((start >= 0 and end < len(haystack) and
             haystack[start:end] == needle) ^ matchnot)
1229179
def unmatched(match):
    """"""
    start, end = match.span(0)
    return match.string[:start]+match.string[end:]
397663
def check_gaps(matches, gap_threshold = 0):
    
    gaps = []
    prev = None
    for match in sorted(matches, key = itemgetter(0)):
        if prev is None:
            prev = match
            continue
        if match[0] - prev[1] >= gap_threshold:
            gaps.append([prev, match])
            prev = match
    return [[i[0][1], i[1][0]] for i in gaps]
318450
def _range_check(self, value, min_value, max_value):
        '''
        
        '''
        if value < min_value or value > max_value:
            raise ValueError('%s out of range - %s is not between %s and %s' % (self.__class__.__name__, value, min_value, max_value))
36719
def match(self, *args):
        """"""
        if self.fall or not args:
            return True
        elif self.value in args: # changed for v1.5, see below
            self.fall = True
            return True
        else:
            return False
945978
static String getQuality(float quality) {
        quality -= 1;
        if (quality == -1) {
            return null;    //Quality missing
        } else {
            String q = Float.toString(quality);
            if (q.endsWith(".0")){
                return q.substring(0, q.lastIndexOf("."));
            } else {
                return q;
            }
        }
    }
1099155
def _value_validate(self, value, rnge, identifier="Given"):
        
        if value is not None and (value < rnge[0] or value > rnge[1]):
            raise ValueError('%s value must be between %d and %d.'
                             % (identifier, rnge[0], rnge[1]))
1258072
function matches(str, match) {
    if (Array.isArray(match)) {
        var l = match.length;
        for( var s=0; s < l; s++) {
            if ( mm(str,match[s])) {
                return true;
            }
        }
        return false;
    }
    return match.test(str);
}
410214
@Override
    public int matches(Replaceable text,
                       int[] offset,
                       int limit,
                       boolean incremental) {
        int c;
        if (offset[0] < limit &&
            contains(c = text.char32At(offset[0]))) {
            offset[0] += UTF16.getCharCount(c);
            return U_MATCH;
        }
        if (offset[0] > limit && contains(text.char32At(offset[0]))) {
            // Backup offset by 1, unless the preceding character is a
            // surrogate pair -- then backup by 2 (keep offset pointing at
            // the lead surrogate).
            --offset[0];
            if (offset[0] >= 0) {
                offset[0] -= UTF16.getCharCount(text.char32At(offset[0])) - 1;
            }
            return U_MATCH;
        }
        if (incremental && offset[0] == limit) {
            return U_PARTIAL_MATCH;
        }
        return U_MISMATCH;
    }
1053835
def field_match(self, node_field, pattern_field):
        
        is_good_list = (isinstance(pattern_field, list) and
                        self.check_list(node_field, pattern_field))
        is_good_node = (isinstance(pattern_field, AST) and
                        Check(node_field,
                              self.placeholders).visit(pattern_field))

        def strict_eq(f0, f1):
            try:
                return f0 == f1 or (isnan(f0) and isnan(f1))
            except TypeError:
                return f0 == f1

        is_same = strict_eq(pattern_field, node_field)
        return is_good_list or is_good_node or is_same
518597
def check_p_equals_zero(text):
    """"""
    err = "psychology.p_equals_zero"
    msg = "Unless p really equals zero, you should use more decimal places."

    list = [
        "p = 0.00",
        "p = 0.000",
        "p = 0.0000",
    ]

    return existence_check(text, list, err, msg, join=True)
808336
def matches(encoding)
      values.select {|v|
        v == encoding || v == '*'
      }.sort {|a, b|
        # "*" gets least precedence, any others should be equal.
        a == '*' ? 1 : (b == '*' ? -1 : 0)
      }
    end
1070240
public Match match(List<String> desired, int threshold) {
    return matchImpl(parse(desired), threshold);
  }
1148
def precise_matcher(text_log_error):
    """"""
    failure_line = text_log_error.metadata.failure_line
    logger.debug("Looking for test match in failure %d", failure_line.id)

    if failure_line.action != "test_result" or failure_line.message is None:
        return

    f = {
        'text_log_error___metadata__failure_line__action': 'test_result',
        'text_log_error___metadata__failure_line__test': failure_line.test,
        'text_log_error___metadata__failure_line__subtest': failure_line.subtest,
        'text_log_error___metadata__failure_line__status': failure_line.status,
        'text_log_error___metadata__failure_line__expected': failure_line.expected,
        'text_log_error___metadata__failure_line__message': failure_line.message
    }
    qwargs = (
        Q(text_log_error___metadata__best_classification=None)
        & (Q(text_log_error___metadata__best_is_verified=True)
           | Q(text_log_error__step__job=text_log_error.step.job))
    )
    qs = (TextLogErrorMatch.objects.filter(**f)
                                   .exclude(qwargs)
                                   .order_by('-score', '-classified_failure'))

    if not qs:
        return

    # chunk through the QuerySet because it could potentially be very large
    # time bound each call to the scoring function to avoid job timeouts
    # returns an iterable of (score, classified_failure_id) tuples
    chunks = chunked_qs_reverse(qs, chunk_size=20000)
    return chain.from_iterable(time_boxed(score_matches, chunks, time_budget=500))