Ejemplo n.º 1
0
def test_perimeter_status_default():
    node_status = nodes.status_with_perimeter_as_boundary((4, 5))
    F, C = CLOSED_BOUNDARY, CORE_NODE
    assert_array_equal(
        node_status,
        [[F, F, F, F, F], [F, C, C, C, F], [F, C, C, C, F], [F, F, F, F, F]])
    assert_array_is_int(node_status)
Ejemplo n.º 2
0
def test_with_ndarray_with_length_0():
    """Test with 0d numpy arrays as args."""
    rmg = RasterModelGrid(4, 5)
    id = rfuncs.find_nearest_node(rmg, (np.array(0.2), np.array(0.6)))
    assert_array_equal(id, np.array(5, dtype=int))
    assert id.ndim == 0
    assert_array_is_int(id)
Ejemplo n.º 3
0
def test_with_scalars():
    """Test scalar args."""
    rmg = RasterModelGrid(4, 5)
    id = rfuncs.find_nearest_node(rmg, (0.2, 0.6))
    assert id == 5
    assert id.ndim == 0
    assert_array_is_int(id)
Ejemplo n.º 4
0
def test_active_links_ids():
    status = np.empty((4, 5), dtype=int)
    status.fill(CLOSED_BOUNDARY)
    status[1, 2] = status[1, 3] = status[2, 2] = status[2, 3] = CORE_NODE

    link_ids = active_link_ids((4, 5), status)
    assert_array_equal(link_ids, [7, 8, 21, 25])
    assert_array_is_int(link_ids)
Ejemplo n.º 5
0
def test_perimeter_status_default():
    node_status = nodes.status_with_perimeter_as_boundary((4, 5))
    F, C = NodeStatus.CLOSED, NodeStatus.CORE
    assert_array_equal(
        node_status,
        [[F, F, F, F, F], [F, C, C, C, F], [F, C, C, C, F], [F, F, F, F, F]],
    )
    assert_array_is_int(node_status)
Ejemplo n.º 6
0
def test_perimeter_status_status_as_scalar():
    node_status = nodes.status_with_perimeter_as_boundary(
        (4, 5), node_status=CLOSED_BOUNDARY)
    B, C = CLOSED_BOUNDARY, CORE_NODE
    assert_array_equal(
        node_status,
        [[B, B, B, B, B], [B, C, C, C, B], [B, C, C, C, B], [B, B, B, B, B]])
    assert_array_is_int(node_status)
Ejemplo n.º 7
0
def test_perimeter_status_default():
    node_status = nodes.status_with_perimeter_as_boundary((4, 5))
    F, C = CLOSED_BOUNDARY, CORE_NODE
    assert_array_equal(
        node_status,
        [[F, F, F, F, F], [F, C, C, C, F], [F, C, C, C, F], [F, F, F, F, F]],
    )
    assert_array_is_int(node_status)
Ejemplo n.º 8
0
def test_perimeter_status_status_as_array():
    F, B, C = FIXED_VALUE_BOUNDARY, CLOSED_BOUNDARY, CORE_NODE
    status = [F, F, F, F, F, F, B, F, B, B, B, B, B, B]
    node_status = nodes.status_with_perimeter_as_boundary((4, 5),
                                                          node_status=status)
    assert_array_equal(
        node_status,
        [[F, F, F, F, F], [F, C, C, C, B], [F, C, C, C, B], [B, B, B, B, B]])
    assert_array_is_int(node_status)
Ejemplo n.º 9
0
def test_perimeter_status_status_as_array():
    F, B, C = FIXED_VALUE_BOUNDARY, CLOSED_BOUNDARY, CORE_NODE
    status = [F, F, F, F, F, F, B, F, B, B, B, B, B, B]
    node_status = nodes.status_with_perimeter_as_boundary((4, 5), node_status=status)
    assert_array_equal(
        node_status,
        [[F, F, F, F, F], [F, C, C, C, B], [F, C, C, C, B], [B, B, B, B, B]],
    )
    assert_array_is_int(node_status)
Ejemplo n.º 10
0
def test_active_links_ids():
    status = np.empty((4, 5), dtype=int)
    status.fill(CLOSED_BOUNDARY)
    status[1, 2] = status[1, 3] = status[2, 2] = status[2, 3] = CORE_NODE

    link_ids = active_link_ids((4, 5), status)
    assert_array_equal(link_ids, [11, 15, 16, 20])
    # assert_array_equal(link_ids, [7, 8, 21, 25])
    assert_array_is_int(link_ids)
Ejemplo n.º 11
0
def test_perimeter_status_status_as_scalar():
    node_status = nodes.status_with_perimeter_as_boundary(
        (4, 5), node_status=NodeStatus.CLOSED)
    B, C = NodeStatus.CLOSED, NodeStatus.CORE
    assert_array_equal(
        node_status,
        [[B, B, B, B, B], [B, C, C, C, B], [B, C, C, C, B], [B, B, B, B, B]],
    )
    assert_array_is_int(node_status)
Ejemplo n.º 12
0
def test_perimeter_status_status_as_array():
    F, B, C = NodeStatus.FIXED_VALUE, NodeStatus.CLOSED, NodeStatus.CORE
    status = [F, F, F, F, F, F, B, F, B, B, B, B, B, B]
    node_status = nodes.status_with_perimeter_as_boundary((4, 5),
                                                          node_status=status)
    assert_array_equal(
        node_status,
        [[F, F, F, F, F], [F, C, C, C, B], [F, C, C, C, B], [B, B, B, B, B]],
    )
    assert_array_is_int(node_status)
Ejemplo n.º 13
0
def test_perimeter_status_status_as_scalar():
    node_status = nodes.status_with_perimeter_as_boundary(
        (4, 5), node_status=CLOSED_BOUNDARY)
    B, C = CLOSED_BOUNDARY, CORE_NODE
    assert_array_equal(node_status,
                       [[B, B, B, B, B],
                        [B, C, C, C, B],
                        [B, C, C, C, B],
                        [B, B, B, B, B]])
    assert_array_is_int(node_status)
Ejemplo n.º 14
0
def test_perimeter_nodes():
    node_ids = nodes.perimeter((4, 5))
    assert_array_equal(node_ids,
                       [0, 1, 2, 3, 4, 5, 9, 10, 14, 15, 16, 17, 18, 19])
    assert_array_is_int(node_ids)
Ejemplo n.º 15
0
def test_with_scalars():
    rmg = RasterModelGrid(4, 5)
    id = rfuncs.find_nearest_node(rmg, (0.2, 0.6))
    assert_equal(id, 5)
    assert_equal(id.ndim, 0)
    assert_array_is_int(id)
Ejemplo n.º 16
0
def test_with_ndarray_with_length_0():
    rmg = RasterModelGrid(4, 5)
    id = rfuncs.find_nearest_node(rmg, (np.array(0.2), np.array(0.6)))
    assert_array_equal(id, np.array(5, dtype=int))
    assert_equal(id.ndim, 0)
    assert_array_is_int(id)
Ejemplo n.º 17
0
def test_with_iterable():
    """Test iterable args."""
    rmg = RasterModelGrid(4, 5)
    id = rfuncs.find_nearest_node(rmg, ([0.2], [0.6]))
    assert_array_equal(id, np.array([5], dtype=int))
    assert_array_is_int(id)
Ejemplo n.º 18
0
def test_perimeter_nodes():
    node_ids = nodes.perimeter((4, 5))
    assert_array_equal(node_ids,
                       [0, 1, 2, 3, 4, 5, 9, 10, 14, 15, 16, 17, 18, 19])
    assert_array_is_int(node_ids)
Ejemplo n.º 19
0
def test_active_links_with_edge_boundaries():
    status = status_with_perimeter_as_boundary((3, 4))
    link_ids = active_link_ids((3, 4), status)
    assert_array_equal(link_ids, [8])
    assert_array_is_int(link_ids)