예제 #1
0
def test_initialize_from_file_like():
    config = StringIO(yaml.dump({"shape": [7, 5]}))
    model = BmiHeat()
    model.initialize(config)

    ndim = model.get_grid_rank(0)
    shape = np.empty(ndim, dtype=np.int32)

    assert_array_equal(model.get_grid_shape(0, shape), (7, 5))
예제 #2
0
def test_initialize_from_file():
    import os
    import yaml
    import tempfile

    with tempfile.NamedTemporaryFile("w", delete=False) as fp:
        fp.write(yaml.dump({"shape": [7, 5]}))
        name = fp.name

    model = BmiHeat()
    model.initialize(name)

    os.remove(name)

    ndim = model.get_grid_rank(0)
    shape = np.empty(ndim, dtype=np.int32)

    assert_array_equal(model.get_grid_shape(0, shape), (7, 5))
예제 #3
0
def test_grid_var_rank_fail():
    model = BmiHeat()
    model.initialize()
    model.get_grid_rank(invalid_grid_id)
예제 #4
0
def test_grid_var_rank():
    model = BmiHeat()
    model.initialize()
    assert_equal(model.get_grid_rank(grid_id), 2)
예제 #5
0
def test_grid_var_rank_fail():
    model = BmiHeat()
    model.initialize()
    with pytest.raises(KeyError):
        model.get_grid_rank(invalid_grid_id)
예제 #6
0
def test_grid_var_origin():
    model = BmiHeat()
    model.initialize()
    ndim = model.get_grid_rank(0)
    origin = np.empty(ndim, dtype=np.int32)
    assert_array_equal(model.get_grid_origin(grid_id, origin), (0.0, 0.0))
예제 #7
0
def test_grid_var_spacing():
    model = BmiHeat()
    model.initialize()
    ndim = model.get_grid_rank(0)
    spacing = np.empty(ndim, dtype=np.int32)
    assert_array_equal(model.get_grid_spacing(grid_id, spacing), (1.0, 1.0))
예제 #8
0
def test_grid_var_shape():
    model = BmiHeat()
    model.initialize()
    ndim = model.get_grid_rank(0)
    shape = np.empty(ndim, dtype=np.int32)
    assert_array_equal(model.get_grid_shape(grid_id, shape), (10, 20))
예제 #9
0
def test_grid_var_rank_fail():
    model = BmiHeat()
    model.initialize()
    model.get_grid_rank(invalid_grid_id)
예제 #10
0
def test_grid_var_rank():
    model = BmiHeat()
    model.initialize()
    assert_equal(model.get_grid_rank(grid_id), 2)