<commit_before>from __future__ import absolute_import
from itertools import product
from six.moves import map

cnfClass = None

class Variable(object):
    def __init__(self, name, inverted=False):
        self.name = name
        self.inverted = inverted

    def __neg__(self):
        v = Variable(self.name)
        v.inverted = not self.inverted
        return v

    def __and__(self, other):
        c = cnfClass.create_from(self)
        return c & other

    def __or__(self, other):
        c = cnfClass.create_from(self)
        return c | other

    def __xor__(self, other):
        c = cnfClass.create_from(self)
        return c ^ other

    def __rshift__(self, other): # implies
        c = cnfClass.create_from(self)
        return -c | other

    def __str__(self):
        return ("-" if self.inverted else "") + str(self.name)

    def __eq__(self, other):
        return self.name == other.name and self.inverted == other.inverted

    def __hash__(self):
        return hash(self.name) ^ hash(self.inverted)

    def __cmp__(self, other):
        if self == other:
            return 0
        if (self.name, self.inverted) < (other.name, other.inverted):
            return -1
        else:
            return 1

class NaiveCnf(object):
    def __init__(self):
        self.dis = frozenset()

    @classmethod
    def create_from(cls, x):
        if isinstance(x, Variable):
            cnf = NaiveCnf()
            cnf.dis = frozenset([frozenset([x])])
            return cnf
        elif isinstance(x, cls):
            return x
        else:
            raise Exception("Could not create a Cnf object from %s" % str(type(x)))

    def __and__(self, other):
        other = NaiveCnf.create_from(other)
        result = NaiveCnf()
        result.dis = self.dis | other.dis
        return result

    def __or__(self, other):
        other = NaiveCnf.create_from(other)

        if self.dis and other.dis:
            new_dis = frozenset(
                d1 | d2<commit_msg>Fixed variable comparison to use total_ordering<commit_after>from __future__ import absolute_import
from itertools import product
from six.moves import map
from functools import total_ordering

cnfClass = None

@total_ordering
class Variable(object):
    def __init__(self, name, inverted=False):
        self.name = name
        self.inverted = inverted

    def __neg__(self):
        v = Variable(self.name)
        v.inverted = not self.inverted
        return v

    def __and__(self, other):
        c = cnfClass.create_from(self)
        return c & other

    def __or__(self, other):
        c = cnfClass.create_from(self)
        return c | other

    def __xor__(self, other):
        c = cnfClass.create_from(self)
        return c ^ other

    def __rshift__(self, other): # implies
        c = cnfClass.create_from(self)
        return -c | other

    def __str__(self):
        return ("-" if self.inverted else "") + str(self.name)

    def __eq__(self, other):
        return self.name == other.name and self.inverted == other.inverted

    def __hash__(self):
        return hash(self.name) ^ hash(self.inverted)

    def __cmp__(self, other):
        if self == other:
            return 0
        if (self.name, self.inverted) < (other.name, other.inverted):
            return -1
        else:
            return 1

    def __lt__(self, other):
        return self.__cmp__(other) == -1

class NaiveCnf(object):
    def __init__(self):
        self.dis = frozenset()

    @classmethod
    def create_from(cls, x):
        if isinstance(x, Variable):
            cnf = NaiveCnf()
            cnf.dis = frozenset([frozenset([x])])
            return cnf
        elif isinstance(x, cls):
            return x
        else:
            raise Exception("Could not create a Cnf object from %s" % str(type(x)))

    def __and__(self, other):
        other = NaiveCnf.create_from(other)
        result = NaiveCnf()
        result.dis = self.dis | other.dis
        return result

    def __or__(self, other):
        other = NaiveCnf.create_from(other)

        if self.dis and other.dis:
            new_dis = frozenset(
                d1 | d2
{'fraction_non_alphanumeric': 0.09942224362060664, 'fraction_numerical': 0.0026480500722195475, 'mean_word_length': 2.0573951434878586, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1014644', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1249, 'n_words': 345}