Ejemplo n.º 1
0
def test_vertical_active_link_ids():
    links = sgrid.vertical_active_link_ids((3, 4))
    assert_array_equal(links, np.array([[0, 1], [2, 3]]))

    links = sgrid.vertical_active_link_ids((1, 4))
    expected = np.array([], ndmin=2, dtype=np.int64)
    expected.shape = (0, 2)
    assert_array_equal(expected, links)

    links = sgrid.vertical_active_link_ids((4, 1))
    expected.shape = (3, 0)
    assert_array_equal(expected, links)

    node_status = np.ones((4, 5), dtype=int)
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]))

    node_status = np.ones((4, 5), dtype=int)
    node_status[1, 1] = 0
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[-1, 0, 1], [-1, 2, 3], [4, 5, 6]]))

    node_status[2, 1] = 0
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[-1, 0, 1], [-1, 2, 3], [-1, 4, 5]]))

    node_status[0, 0] = 0
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[-1, 0, 1], [-1, 2, 3], [-1, 4, 5]]))
Ejemplo n.º 2
0
def test_vertical_active_link_ids():
    links = sgrid.vertical_active_link_ids((3, 4))
    assert_array_equal(links, np.array([[0, 1], [2, 3]]))

    links = sgrid.vertical_active_link_ids((1, 4))
    expected = np.array([], ndmin=2, dtype=np.int64)
    expected.shape = (0, 2)
    assert_array_equal(expected, links)

    links = sgrid.vertical_active_link_ids((4, 1))
    expected.shape = (3, 0)
    assert_array_equal(expected, links)

    node_status = np.ones((4, 5), dtype=int)
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]))

    node_status = np.ones((4, 5), dtype=int)
    node_status[1, 1] = 0
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[-1, 0, 1], [-1, 2, 3], [4, 5, 6]]))

    node_status[2, 1] = 0
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[-1, 0, 1], [-1, 2, 3], [-1, 4, 5]]))

    node_status[0, 0] = 0
    links = sgrid.vertical_active_link_ids((4, 5), node_status=node_status)
    assert_array_equal(links, np.array([[-1, 0, 1], [-1, 2, 3], [-1, 4, 5]]))