Пример #1
0
def test_length_of_face():
    """Test length of faces."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))

    assert graph.length_of_face == approx(1.5)
Пример #2
0
def test_cells_at_face():
    """Test cells on either side of faces."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(graph.cells_at_face,
                       [[-1, 0], [0, -1], [-1, 0], [0, -1]])
Пример #3
0
def test_face_dirs_at_corner():
    """Test face directions at corners."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(
        graph.face_dirs_at_corner,
        [[-1, -1, 0, 0], [0, -1, 1, 0], [-1, 0, 0, 1], [0, 0, 1, 1]])
Пример #4
0
def test_faces_at_corner():
    """Test faces around corners."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(
        graph.faces_at_corner,
        [[0, 1, -1, -1], [-1, 2, 0, -1], [3, -1, -1, 1], [-1, -1, 3, 2]])
Пример #5
0
def test_cells_at_corner():
    """Test areas of patches."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(
        graph.cells_at_corner,
        [[0, -1, -1, -1], [-1, 0, -1, -1], [-1, -1, -1, 0], [-1, -1, 0, -1]])
Пример #6
0
def test_length_of_face():
    """Test length of faces."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))

    assert_array_almost_equal(graph.length_of_face, [1.5, 1.5, 1.5, 1.5])
    assert_array_almost_equal(graph.width_of_face, [1.5, 1.5, 1.5, 1.5])
    assert_is(graph.length_of_face, graph.width_of_face)
Пример #7
0
def test_cell_at_node():
    """Test cell-node connectivity."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(graph.cell_at_node, [-1, -1, -1, -1, 0, -1, -1, -1, -1])

    graph = DualUniformRectilinearGraph((3, 4))
    assert_array_equal(graph.cell_at_node,
                       [-1, -1, -1, -1, -1, 0, 1, -1, -1, -1, -1, -1])
Пример #8
0
def test_create():
    """Test creating a quad graph."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))

    assert graph.number_of_nodes == 9
    assert graph.number_of_links == 12
    assert graph.number_of_patches == 4

    assert graph.number_of_corners == 4
    assert graph.number_of_faces == 4
    assert graph.number_of_cells == 1
Пример #9
0
def test_create():
    """Test creating a quad graph."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))

    assert_equal(graph.number_of_nodes, 9)
    assert_equal(graph.number_of_links, 12)
    assert_equal(graph.number_of_patches, 4)

    assert_equal(graph.number_of_corners, 4)
    assert_equal(graph.number_of_faces, 4)
    assert_equal(graph.number_of_cells, 1)
Пример #10
0
def test_corners_at_face():
    """Test corners at face tail and head."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(graph.corners_at_face, [[0, 1], [0, 2], [1, 3], [2, 3]])
Пример #11
0
def test_faces_at_cell():
    """Test faces that form cells."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(graph.faces_at_cell, [[2, 3, 1, 0]])
Пример #12
0
def test_corners_at_cell():
    """Test corners of cells."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3), sort=True)
    assert_array_equal(graph.corners_at_cell, [[3, 2, 0, 1]])
Пример #13
0
def test_area_of_cell():
    """Test areas of patches."""
    y = [0, 0, 0, 1, 1, 1, 3, 3, 3]
    x = [3, 4, 6, 3, 4, 6, 3, 4, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert graph.area_of_cell == approx([2.25])
Пример #14
0
def test_perimeter_corners():
    """Test the perimeter corners."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_equal(graph.perimeter_corners, [1, 3, 2, 0])
Пример #15
0
def test_area_of_cell():
    """Test areas of patches."""
    y = [0, 1, 3, 0, 1, 3, 0, 1, 3]
    x = [3, 3, 3, 4, 4, 4, 6, 6, 6]
    graph = DualStructuredQuadGraph((y, x), shape=(3, 3))
    assert_array_almost_equal(graph.area_of_cell, [2.25])