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))
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))
def test_grid_var_rank_fail(): model = BmiHeat() model.initialize() model.get_grid_rank(invalid_grid_id)
def test_grid_var_rank(): model = BmiHeat() model.initialize() assert_equal(model.get_grid_rank(grid_id), 2)
def test_grid_var_rank_fail(): model = BmiHeat() model.initialize() with pytest.raises(KeyError): model.get_grid_rank(invalid_grid_id)
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))
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))
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))