Exemple #1
0
def test_find_cycle(known_net):
    """Test find_a_cycle() by creating one."""
    links = known_net.links
    links = lnu.flip_link(links, 964)
    c_nodes, c_links = di.find_a_cycle(links, known_net.nodes)
    # make assertions
    assert c_nodes == [761, 784]
    assert c_links == [964, 964]
Exemple #2
0
def test_fix_cycles(known_net):
    """Test fix_cycles()."""
    links = known_net.links
    nodes = known_net.nodes
    # check that cycle exists
    c_nodes, c_links = di.find_a_cycle(links, nodes)
    assert c_nodes == [761, 784]
    assert c_links == [964, 964]
    # check that there are no continuity issues
    problem_nodes = di.check_continuity(links, nodes)
    assert problem_nodes == []
    # now try to fix the cycles
    links, nodes, n_cycles = di.fix_cycles(links, nodes)
Exemple #3
0
def test_fix_delta_cycles(known_net):
    """Test fix_delta_cycles()."""
    links = known_net.links
    nodes = known_net.nodes
    imshape = known_net.Imask.shape
    # check if a cycle exists
    c_nodes, c_links = di.find_a_cycle(links, nodes)
    assert c_nodes == [761, 784]
    assert c_links == [964, 964]
    # verify that no continuity issues exist
    problem_nodes = di.check_continuity(links, nodes)
    assert problem_nodes == []
    # try to fix the cycle
    links, nodes, allfixed = dd.fix_delta_cycles(links, nodes, imshape)
Exemple #4
0
def test_fix_cycles_river(known_river):
    """Test fix_cycles() with river example."""
    links = known_river.links
    nodes = known_river.nodes
    # flip link to create a cycle
    links = lnu.flip_link(links, 2494)
    # check that cycle exists
    c_nodes, c_links = di.find_a_cycle(links, nodes)
    assert c_nodes == [1794, 1805]
    assert c_links == [2494, 2494]
    # check that there are no continuity issues
    problem_nodes = di.check_continuity(links, nodes)
    assert problem_nodes == []
    # now try to fix the cycles
    links, nodes, n_cycles = di.fix_cycles(links, nodes)