コード例 #1
0
def test_issue_90():
    # https://github.com/goodmami/penman/issues/90

    g = Graph([('i', ':instance', 'iota'), ('i2', ':instance', 'i'),
               ('i', ':ARG0', 'i2')],
              top='i')
    assert reconfigure(g) == Tree(('i', [('/', 'iota'),
                                         (':ARG0', ('i2', [('/', 'i')]))]))
コード例 #2
0
def test_reconfigure():
    g = codec.decode('''
        (a / alpha
           :ARG0 b
           :ARG1 (g / gamma
                    :ARG0-of (b / beta)))''')
    # original order reconfiguration puts node definitions at first
    # appearance of a variable
    assert reconfigure(g) == Tree(
        ('a', [('/', 'alpha'), (':ARG0', ('b', [('/', 'beta')])),
               (':ARG1', ('g', [('/', 'gamma'), (':ARG0-of', 'b')]))]))
    # canonical order reconfiguration can also shift things like
    # inverted arguments
    assert reconfigure(g, key=model.canonical_order) == Tree(
        ('a', [('/', 'alpha'),
               (':ARG0', ('b', [('/', 'beta'),
                                (':ARG0', ('g', [('/', 'gamma')]))])),
               (':ARG1', 'g')]))
コード例 #3
0
ファイル: __main__.py プロジェクト: Herobring/penman
def _process_out(g, model, normalize_options):
    if normalize_options['reconfigure']:
        key, kwargs = normalize_options['reconfigure']
        t = layout.reconfigure(g, key=key, **kwargs)
        g = layout.interpret(t, model)
    else:
        t = layout.configure(g, model=model)
    if normalize_options['rearrange']:
        key, kwargs = normalize_options['rearrange']
        layout.rearrange(t, key=key, **kwargs)
    if normalize_options['make_variables']:
        t.reset_variables(normalize_options['make_variables'])

    return t