コード例 #1
0
def test_nest_chain():
    """
    We test the following in pseudo-code

    for a in [0, 1, 2]:
        b()
        c()

    Both 'b' and 'c' depend on 'a'
    """
    a = ParamSpec("a", paramtype="numeric")
    b = ParamSpec("b", paramtype="numeric")
    c = ParamSpec("c", paramtype="numeric")

    table_a = ParamTable([a])
    table_b = ParamTable([b])
    table_c = ParamTable([c])

    table_result = table_a.nest(table_b.chain(table_c))
    table_result.resolve_dependencies()

    # Extract specs from the table
    table_specs = table_result.param_specs
    assert len(table_specs) == 3

    assert table_specs[0].name == 'a'
    assert table_specs[0].depends_on == ''

    assert table_specs[1].name == 'b'
    assert table_specs[1].depends_on == 'a'

    assert table_specs[2].name == 'c'
    assert table_specs[2].depends_on == 'a'
コード例 #2
0
def test_chain():
    """
    Test simple chaining
    """
    a = ParamSpec("a", paramtype="numeric")
    b = ParamSpec("b", paramtype="numeric")

    table_a = ParamTable([a])
    table_b = ParamTable([b])

    table_chain = table_a.chain(table_b)
    table_chain.resolve_dependencies()

    # Extract specs from the table
    table_specs = table_chain.param_specs
    assert len(table_specs) == 2

    assert table_specs[0].name == 'a'
    assert table_specs[0].depends_on == ''

    assert table_specs[1].name == 'b'
    assert table_specs[1].depends_on == ''