Ejemplo n.º 1
0
def test_add_boundary_data():

    grid = two_triangles()

    print(grid.boundaries)

    # add the boundary definitions:
    grid.boundaries = [
        (0, 1),
        (0, 2),
        (1, 3),
        (2, 3),
    ]
    # create a UVar object for boundary conditions:
    bnds = UVar('bounds', location='boundary', data=[0, 1, 0, 0, 1])
    bnds.attributes["long_name"] = "model boundary conditions"

    # wrong size for data
    with pytest.raises(ValueError):
        grid.add_data(bnds)
    # correct data
    bnds.data = [0, 1, 0, 0]
    grid.add_data(bnds)

    assert grid.data['bounds'].name == 'bounds'
    assert np.array_equal(grid.data['bounds'].data, [0, 1, 0, 0])
Ejemplo n.º 2
0
def test_add_boundary_data():

    grid = two_triangles()

    print(grid.boundaries)

    # add the boundary definitions:
    grid.boundaries = [(0,1),
                       (0,2),
                       (1,3),
                       (2,3),
                      ]
    # create a UVar object for boundary conditions:
    bnds = UVar('bounds', location='boundary', data=[0, 1, 0, 0, 1])
    bnds.attributes["long_name"] = "model boundary conditions"

    # wrong size for data
    with pytest.raises(ValueError):
        grid.add_data(bnds)
    # correct data
    bnds.data = [0, 1, 0, 0]
    grid.add_data(bnds)

    assert grid.data['bounds'].name == 'bounds'
    assert np.array_equal( grid.data['bounds'].data, [0, 1, 0, 0] )
Ejemplo n.º 3
0
def test_add_data():
    d = UVar('depth', location='node')
    assert d.name == 'depth'
    assert np.array_equal(d.data, [])

    # Add the data:
    d.data = [1.0, 2.0, 3.0, 4.0]

    assert np.array_equal(d.data, [1.0, 2.0, 3.0, 4.0])
    # Duck type check of nd.ndarray.
    d.data *= 2
    assert np.array_equal(d.data, [2.0, 4.0, 6.0, 8.0])