<commit_before>from noodles import schedule, run_single, unwrap, run_process, Storable
from noodles import serial
from nose.tools import raises


@schedule
def sqr(x):
    return x*x


@schedule
def divide(x, y):
    return x/y


@schedule
def mul(x, y):
    return x*y


@schedule
def make_object(cls, *args, **kwargs):
    return cls(*args, **kwargs)


class A(Storable):
    def __init__(self, value):
        # super(A, self).__init__()
        self.value = value
        self.m_attr = 0

    @property
    def attr(self):
        return sqr(self.m_attr)

    def mul_attr(self, factor=1):
        return mul(self.m_attr, factor)

    @attr.setter
    def attr(self, x):
        self.m_attr = divide(x, 2)

    def multiply(self, factor):
        self.value *= factor
        return self


class B:
    pass


def test_class_decorator():
    a = make_object(A, 5).multiply(10)
    a.second = 7
    result = run_single(a)
    assert result.value == 50
    assert result.second == 7


def registry():
    return serial.base()


def test_class_decorator_process():
    from noodles.draw_workflow import draw_workflow
    a = make_object(A, 5).multiply(10)
    a.second = 7
    draw_workflow('wf.svg', a._workflow)
    result = run_process(
        a, n_processes=1, registry=registry)
    assert result.value == 50
    assert result.second == 7


def test_class_property():
    a = make_object(A, 10)<commit_msg>remove drawing workflow from test<commit_after>from noodles import schedule, run_single, unwrap, run_process, Storable
from noodles import serial
from nose.tools import raises


@schedule
def sqr(x):
    return x*x


@schedule
def divide(x, y):
    return x/y


@schedule
def mul(x, y):
    return x*y


@schedule
def make_object(cls, *args, **kwargs):
    return cls(*args, **kwargs)


class A(Storable):
    def __init__(self, value):
        # super(A, self).__init__()
        self.value = value
        self.m_attr = 0

    @property
    def attr(self):
        return sqr(self.m_attr)

    def mul_attr(self, factor=1):
        return mul(self.m_attr, factor)

    @attr.setter
    def attr(self, x):
        self.m_attr = divide(x, 2)

    def multiply(self, factor):
        self.value *= factor
        return self


class B:
    pass


def test_class_decorator():
    a = make_object(A, 5).multiply(10)
    a.second = 7
    result = run_single(a)
    assert result.value == 50
    assert result.second == 7


def registry():
    return serial.base()


def test_class_decorator_process():
    a = make_object(A, 5).multiply(10)
    a.second = 7
    result = run_process(
        a, n_processes=1, registry=registry)
    assert result.value == 50
    assert result.second == 7


def test_class_property():
    a = make_object(A, 10)
{'fraction_non_alphanumeric': 0.11333091173265529, 'fraction_numerical': 0.01452960406828914, 'mean_word_length': 2.8356545961002784, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6317521', 'n_tokens_mistral': 991, 'n_tokens_neox': 917, 'n_words': 253}