Esempio n. 1
0
def test_bad_boundary_condition_yaml(bad_handler_yaml, tmpdir):
    with tmpdir.as_cwd():
        with open("params.yaml", "w") as fp:
            fp.write(bad_handler_yaml)

        with pytest.raises(ValueError):
            ErosionModel.from_file("./params.yaml")
Esempio n. 2
0
def test_input_file(tmpdir, inputs_yaml):
    with tmpdir.as_cwd():
        with open("params.yaml", "w") as fp:
            fp.write(inputs_yaml)

        em = ErosionModel.from_file("./params.yaml")

    assert isinstance(em.grid, HexModelGrid)
    assert em.grid.number_of_nodes == 56
    for field in at_node_fields:
        assert field in em.grid.at_node
    assert isinstance(em.flow_accumulator, FlowAccumulator) is True
    assert em.flow_accumulator.flow_director._name == "FlowDirectorSteepest"
    assert em.boundary_handlers == {}
    assert em.output_writers == {}
    assert em.save_first_timestep is True
    assert em._out_file_name == "terrainbento_output"
    assert em._model_time == 0.0
Esempio n. 3
0
def test_string_D8(tmpdir, inputs_D8_yaml):
    with tmpdir.as_cwd():
        with open("params.yaml", "w") as fp:
            fp.write(inputs_D8_yaml)

        with open("./params.yaml", "r") as f:
            contents = f.read()

    em = ErosionModel.from_file(contents)
    assert isinstance(em.grid, RasterModelGrid)
    assert em.grid.number_of_nodes == 20
    for field in at_node_fields:
        assert field in em.grid.at_node
    assert isinstance(em.flow_accumulator, FlowAccumulator) is True
    assert em.flow_accumulator.flow_director._name == "FlowDirectorD8"
    assert em.boundary_handlers == {}
    assert em.all_output_writers == []
    assert em.save_first_timestep is True
    assert em.output_prefix == "terrainbento-output"
    assert em._model_time == 0.0
Esempio n. 4
0
def test_no_grid_in_file(tmpdir, basic_inputs_no_grid_yaml):
    with tmpdir.as_cwd():
        with open("params.yaml", "w") as fp:
            fp.write(basic_inputs_no_grid_yaml)
        with pytest.raises(ValueError):
            ErosionModel.from_file("./params.yaml")
Esempio n. 5
0
def test_bad_precipitator_params(tmpdir, basic_inputs_bad_precipitator_yaml):
    with tmpdir.as_cwd():
        with open("params.yaml", "w") as fp:
            fp.write(basic_inputs_bad_precipitator_yaml)
        with pytest.raises(ValueError):
            ErosionModel.from_file("./params.yaml")