<commit_before>import math, operator
from . address import Address

"""
Simple numerical operations put together in a list, useful for
scaling or offsetting some incoming numerical value.

Examples:

   Ops()(x)
returns the number unchanged

   Ops('mul', 0.5)(x)
multiples x by 0.5

   Ops('add', 0.1)(x)
adds 1 to x

   Ops('sqrt')(x)
returns the square root of x

   Ops('mul', 0.5, 'add', 1, 'sqrt')(x)
returns sqrt(1 + 0.5 * x)

"""


class Op:
    def __init__(self, op, *values):
        if len(values) > len(OPS):
            raise KeyError('Too many arguments for ' + op)
        ops = OPS[len(values)]

        if op not in ops:
            raise KeyError(OPS_ERROR.format(op, ', '.join(sorted(ops))))
        self.op = ops[op]

        self.opname = op
        self.values = values

    def __call__(self, x):
        return self.op(x, *self.values)

    def __str__(self):
        values = ', '.join(str(v) for v in self.values)
        return '%s(%s)' % self.opname, values


class Ops:
    def __init__(self, *ops):
        self.ops = tuple(_make_ops(ops))

    def __call__(self, x):
        for op in self.ops:<commit_msg>Clean up control/ops.py slightly<commit_after>"""
Simple numerical operations put together in a list, useful for
scaling or offsetting some incoming numerical value.

Examples:

   Ops()(x)
returns the number unchanged

   Ops('mul', 0.5)(x)
multiples x by 0.5

   Ops('add', 0.1)(x)
adds 1 to x

   Ops('sqrt')(x)
returns the square root of x

   Ops('mul', 0.5, 'add', 1, 'sqrt')(x)
returns sqrt(1 + 0.5 * x)

"""

import math, operator


class Op:
    def __init__(self, op, *values):
        if len(values) > len(OPS):
            raise KeyError('Too many arguments for ' + op)
        ops = OPS[len(values)]

        if op not in ops:
            raise KeyError(OPS_ERROR.format(op, ', '.join(sorted(ops))))
        self.op = ops[op]

        self.opname = op
        self.values = values

    def __call__(self, x):
        return self.op(x, *self.values)

    def __str__(self):
        values = ', '.join(str(v) for v in self.values)
        return '%s(%s)' % self.opname, values


class Ops:
    def __init__(self, *ops):
        self.ops = tuple(_make_ops(ops))

    def __call__(self, x):
        for op in self.ops:
{'fraction_non_alphanumeric': 0.1390728476821192, 'fraction_numerical': 0.011479028697571744, 'mean_word_length': 2.540625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7288968', 'n_tokens_mistral': 814, 'n_tokens_neox': 753, 'n_words': 241}