<commit_before># -*- coding: utf-8 -*-
from six import with_metaclass

from formidable.utils import singleton


class FunctionRegister(dict, singleton):
    pass


class FunctionMetaClass(type):

    def __new__(mcls, name, base, attrs):
        klass = super(FunctionMetaClass, mcls).__new__(mcls, name, base, attrs)
        if hasattr(klass, 'Meta'):
            register = FunctionRegister.get_instance()
            register[klass.Meta.name] = klass
        return klass


class Function(with_metaclass(FunctionMetaClass)):
    pass


class IsEmpty(Function):

    class Meta:
        name = 'is_empty'

    def __call__(self, value):
        return value in [None, '', 0, False]


class Add(Function):

    class Meta:
        name = 'add'

    def __call__(self, x, y):
        return x + y


class Sub(Function):

    class Meta:
        name = 'sub'

    def __call__(self, x, y):
        return x - y


class Mult(Function):

    class Meta:
        name = 'mult'

    def __call__(self, x, y):
        return x * y


class Div(Function):

    class Meta:
        name = 'div'

    def __call__(self, x, y):
        if y == 0:
            raise ZeroDivisionError()
        return x / y


class Not(Function):

    class Meta:
        name = 'not'

    def __call__(self, x):
        return not(x)


class Eq(Function):

    class Meta:
        name = 'eq'

    def __call__(self, *args):
        return reduce(lambda x, y: x and y, args)


class Gt(Function):

    class Meta:
        name = 'gt'

    def __call__(self, x, y):
        return x > y


class Gte(Function):

    class Meta:
        name = 'gte'

    def __call__(self, x, y):
        return x >= y


class Lt(Function):

    class Meta:
        name = 'lt'

    def __call__(self, x, y):
        return x < y

<commit_msg>refs #60, fix the equals function<commit_after># -*- coding: utf-8 -*-
from six import with_metaclass

from formidable.utils import singleton


class FunctionRegister(dict, singleton):
    pass


class FunctionMetaClass(type):

    def __new__(mcls, name, base, attrs):
        klass = super(FunctionMetaClass, mcls).__new__(mcls, name, base, attrs)
        if hasattr(klass, 'Meta'):
            register = FunctionRegister.get_instance()
            register[klass.Meta.name] = klass
        return klass


class Function(with_metaclass(FunctionMetaClass)):
    pass


class IsEmpty(Function):

    class Meta:
        name = 'is_empty'

    def __call__(self, value):
        return value in [None, '', 0, False]


class Add(Function):

    class Meta:
        name = 'add'

    def __call__(self, x, y):
        return x + y


class Sub(Function):

    class Meta:
        name = 'sub'

    def __call__(self, x, y):
        return x - y


class Mult(Function):

    class Meta:
        name = 'mult'

    def __call__(self, x, y):
        return x * y


class Div(Function):

    class Meta:
        name = 'div'

    def __call__(self, x, y):
        if y == 0:
            raise ZeroDivisionError()
        return x / y


class Not(Function):

    class Meta:
        name = 'not'

    def __call__(self, x):
        return not(x)


class Eq(Function):

    class Meta:
        name = 'eq'

    def __call__(self, x, y):
        return x == y


class Gt(Function):

    class Meta:
        name = 'gt'

    def __call__(self, x, y):
        return x > y


class Gte(Function):

    class Meta:
        name = 'gte'

    def __call__(self, x, y):
        return x >= y


class Lt(Function):

    class Meta:
        name = 'lt'

    def __call__(self, x, y):
        return x < y


{'fraction_non_alphanumeric': 0.11191738766396875, 'fraction_numerical': 0.0022327658386826683, 'mean_word_length': 2.0606319385140903, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1446688', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1125, 'n_words': 359}