<commit_before>__author__ = "<NAME>"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"

from hamcrest.core.base_matcher import BaseMatcher

if 'cmp' not in globals():
    from  unittest.util import three_way_cmp as cmp


def _comparison(compare):
    if compare > 0:
        return 'less than'
    elif compare == 0:
        return 'equal to'
    else:
        return 'greater than'


class OrderingComparison(BaseMatcher):

    def __init__(self, value, min_compare, max_compare):
        self.value = value
        self.min_compare = min_compare
        self.max_compare = max_compare

    def _matches(self, item):
        compare = cmp(self.value, item)
        return self.min_compare <= compare and compare <= self.max_compare

    def describe_to(self, description):
        description.append_text('a value ')                         \
                   .append_text(_comparison(self.min_compare))
        if self.min_compare != self.max_compare:
            description.append_text(' or ')                         \
                       .append_text(_comparison(self.max_compare))
        description.append_text(' ')                                \
                   .append_description_of(self.value)



def greater_than(value):
    """Is value > expected?"""
    return OrderingComparison(value, -1, -1)

def greater_than_or_equal_to(value):
    """Is value >= expected?"""
    return OrderingComparison(value, -1, 0)

def less_than(value):
    """Is value < expected?"""
    return OrderingComparison(value, 1, 1)

def less_than_or_equal_to(value):
    """Is value <= expected?"""
    return OrderingComparison(value, 0, 1)<commit_msg>unittest.util.three_way_cmp exists available since 3.2<commit_after>__author__ = "<NAME>"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"

from hamcrest.core.base_matcher import BaseMatcher
import operator


class OrderingComparison(BaseMatcher):

    def __init__(self, value, compare_func, comparison):
        self.value = value
        self.compare_func = compare_func
        self.comparison = comparison

    def _matches(self, item):
        return self.compare_func(item, self.value)

    def describe_to(self, description):
        description.append_text('a value ').append_text(self.comparison)
        description.append_text(' ').append_description_of(self.value)



def greater_than(value):
    """Is value > expected?"""
    return OrderingComparison(value, operator.gt, 'greater than')

def greater_than_or_equal_to(value):
    """Is value >= expected?"""
    return OrderingComparison(value, operator.ge, 'greater than or equal to')

def less_than(value):
    """Is value < expected?"""
    return OrderingComparison(value, operator.lt, 'less than')

def less_than_or_equal_to(value):
    """Is value <= expected?"""
    return OrderingComparison(value, operator.le, 'equal to or less than')
{'fraction_non_alphanumeric': 0.10925230454079891, 'fraction_numerical': 0.006828269033799932, 'mean_word_length': 3.115168539325843, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3098564', 'n_tokens_mistral': 883, 'n_tokens_neox': 836, 'n_words': 210}