def test_elsewhere_bundles_not_added_at_minmax_rank_when_one_bundle_defined():
    nodes = {'a': ProcessGroup(selection=['a1'])}
    bundles = {0: Bundle('a', Elsewhere)}
    order = [['a']]
    vd = SankeyDefinition(nodes, bundles, order)
    new_waypoints, new_bundles = elsewhere_bundles(vd)
    assert len(new_waypoints) == 0
    assert len(new_bundles) == 0
Ejemplo n.º 2
0
def test_elsewhere_bundles_not_added_to_waypoints():
    nodes = {'waypoint': Waypoint(), }
    bundles = {}
    order = [[], ['waypoint'], []]
    vd = SankeyDefinition(nodes, bundles, order)
    new_waypoints, new_bundles = elsewhere_bundles(vd)
    assert new_waypoints == {}
    assert new_bundles == {}
def test_elsewhere_bundles_are_not_added_when_disabled():
    nodes = {'a': ProcessGroup(selection=['a1'])}
    bundles = {}
    order = [['a']]
    vd = SankeyDefinition(nodes, bundles, order)
    new_waypoints, new_bundles = elsewhere_bundles(
        vd, add_elsewhere_waypoints=False)
    assert len(new_bundles) == 2
    assert new_waypoints == {}
Ejemplo n.º 4
0
def test_elsewhere_bundles():
    nodes = {'a': ProcessGroup(selection=['a1']), }
    bundles = {}
    order = [[], ['a'], []]  # not at min/max rank
    vd = SankeyDefinition(nodes, bundles, order)
    new_waypoints, new_bundles = elsewhere_bundles(vd)
    assert set(new_waypoints.keys()) == {'__a>', '__>a'}
    assert set(new_bundles.values()) == {
        Bundle('a', Elsewhere, waypoints=['__a>']),
        Bundle(Elsewhere, 'a', waypoints=['__>a']),
    }
def test_elsewhere_bundles_are_added_when_no_bundles_defined():
    # make it easier to get started
    nodes = {'a': ProcessGroup(selection=['a1'])}
    bundles = {}
    order = [['a']]
    vd = SankeyDefinition(nodes, bundles, order)
    new_waypoints, new_bundles = elsewhere_bundles(vd)
    assert len(new_bundles) == 2
    assert new_waypoints == {
        '__>a': Waypoint(title='→'),
        '__a>': Waypoint(title='→'),
    }

    # when direction is to left
    nodes['a'] = ProcessGroup(selection=['a1'], direction='L')
    vd = SankeyDefinition(nodes, bundles, order)
    new_waypoints, new_bundles = elsewhere_bundles(vd)
    assert new_waypoints == {
        '__>a': Waypoint(direction='L', title='←'),
        '__a>': Waypoint(direction='L', title='←'),
    }
def test_elsewhere_bundles_does_not_duplicate():
    nodes = {
        'a': ProcessGroup(selection=('a1')),
        'in': Waypoint(),
        'out': Waypoint()
    }
    bundles = {
        0: Bundle(Elsewhere, 'a', waypoints=['in']),
        1: Bundle('a', Elsewhere, waypoints=['out']),
    }
    order = [['in'], ['a'], ['out']]  # not at min/max rank
    vd = SankeyDefinition(nodes, bundles, order)
    new_waypoints, new_bundles = elsewhere_bundles(vd)
    assert new_bundles == {}