def test_dummy_nodes_order_dependence(): # # a b # c d # # bundles a-b, c-d, b-a G = LayeredGraph() G.add_nodes_from('abcd', node=ProcessGroup()) G.ordering = Ordering([[['a', 'c']], [['b', 'd']]]) # Correct G.order: a-b, c-d, b-a G1 = _apply_bundles(G, ('ab', 'cd', 'ba')) assert G1.ordering == Ordering( [[['a', '__b_a_0', 'c']], [['b', '__b_a_1', 'd']]]) # Incorrect G.order: b-a first G2 = _apply_bundles(G, ('ba', 'ab', 'cd')) assert G2.ordering == Ordering( [[['a', 'c', '__b_a_0']], [['b', '__b_a_1', 'd']]])
def test_augment_waypoint_alignment(): # j -- a -- x # b # k -- c -- y # # should insert "from b" betwen x and y # and "to b" between j and k G = LayeredGraph() G.add_nodes_from([ ('a', {'node': ProcessGroup()}), ('b', {'node': ProcessGroup(selection=['b1'])}), ('c', {'node': ProcessGroup()}), ('x', {'node': ProcessGroup()}), ('y', {'node': ProcessGroup()}), ('j', {'node': ProcessGroup()}), ('k', {'node': ProcessGroup()}), ]) G.add_edges_from([ ('a', 'x', {'bundles': [2]}), ('k', 'c', {'bundles': [1]}), ('j', 'a', {'bundles': [0]}), ('c', 'y', {'bundles': [3]}), ]) G.ordering = Ordering([[['j', 'k']], [['a', 'b', 'c']], [['x', 'y']]]) new_waypoints = { 'from b': Waypoint(), 'to b': Waypoint(), } new_bundles = { 'b>': Bundle('b', Elsewhere, waypoints=['from b']), '>b': Bundle(Elsewhere, 'b', waypoints=['to b']), } G2 = augment(G, new_waypoints, new_bundles) assert set(G2.nodes()).difference(G.nodes()) == {'from b', 'to b'} assert G2.ordering == Ordering([ [['j', 'to b', 'k']], [['a', 'b', 'c']], [['x', 'from b', 'y']] ])