Esempio n. 1
0
def single_node():
    H.dependency_graph.clear()
    register_delayed_value_node(0)
    register_delayed_caller_node(1)
    register_delayed_value_node(2)
    register_function_call(dict(x=0), 1, (2, ))
    yield
    H.dependency_graph.clear()
Esempio n. 2
0
def test_clear(dependency_graph):
    register_delayed_caller_node(1)
    register_delayed_value_node(2)
    dependency_graph.clear()
    assert 1 not in dependency_graph
    assert 1 not in dependency_graph.delayed_callers
    assert 2 not in dependency_graph
    assert 2 not in dependency_graph.delayed_values
    assert register_delayed_caller_node(1) == 0
Esempio n. 3
0
def test_register_multiple_callers(dependency_graph):
    res1 = register_delayed_caller_node(1)
    res2 = register_delayed_caller_node(2)
    res3 = register_delayed_caller_node(3)
    assert 1 in dependency_graph.delayed_callers
    assert 2 in dependency_graph.delayed_callers
    assert 3 in dependency_graph.delayed_callers
    assert 1 in dependency_graph.nodes()
    assert 2 in dependency_graph.nodes()
    assert 3 in dependency_graph.nodes()
    assert res1 == 0
    assert res2 == 1
    assert res3 == 2
Esempio n. 4
0
def build_graph():
    H.dependency_graph.clear()
    for i in range(1, 13):
        register_delayed_value_node(i)
    for i in range(101, 105):
        register_delayed_caller_node(i)
    for i, j in zip(range(70, 74), [1, 2, 3, 6]):
        register_delayed_caller_node(i)
        register_function_call({}, i, (j,))
    register_function_call(dict(x=1, y=2, z=3), 101, (4, 5))
    register_function_call(dict(x=6, y=4), 102, (7, 8))
    register_function_call(dict(x=4, y=5), 103, (9, 10))
    register_function_call(dict(x=7, y=8, z=9, w=10), 104, (11, 12))
    yield
    H.dependency_graph.clear()
Esempio n. 5
0
def test_register_function_call(dependency_graph):
    inputs = dict(x=1, y=2, z=3)
    outputs = (4, 5)
    for x in tuple(inputs.values()) + outputs:
        register_delayed_value_node(x)
    caller = 74
    register_delayed_caller_node(caller)
    register_function_call(inputs, caller, outputs)
    assert sorted(dependency_graph.edges(data=True)) == sorted([(1, caller, {
        'input_name':
        'x'
    }), (2, caller, {
        'input_name': 'y'
    }), (3, caller, {
        'input_name': 'z'
    }), (caller, 4, {
        'output_id': 0
    }), (caller, 5, {
        'output_id': 1
    })])
Esempio n. 6
0
def test_wrong_call_graph_validation(dependency_graph):
    register_delayed_caller_node(1)
    register_delayed_caller_node(2)
    dependency_graph.add_edge(1, 2)
    with pytest.raises(AssertionError):
        dependency_graph.validate()
Esempio n. 7
0
def test_register_delayed_caller(dependency_graph):
    res = register_delayed_caller_node(1)
    assert 1 in dependency_graph.delayed_callers
    assert 1 in dependency_graph.nodes()
    assert res == 0
 def __init__(self, func):
     self.func = func
     self.__caller_id = register_delayed_caller_node(self)
Esempio n. 9
0
def single_caller():
    H.dependency_graph.clear()
    register_delayed_caller_node(1)
    yield
    H.dependency_graph.clear()