def test_add_field_from_function_with_list(at, to_list): grid = RasterModelGrid((20, 30)) functions = to_list([ ("constant", dict(value=1.0)), ("constant", dict(value=2.0)), ("constant", dict(value=3.0)), ("constant", dict(value=4.0)), ("constant", dict(value=5.0)), ]) add_field_from_function(grid, "z", functions, at=at) assert_array_almost_equal(grid[at]["z"], 15.0)
def test_add_field_from_function_with_list(at, to_list): grid = RasterModelGrid((20, 30)) functions = to_list( [ ("constant", dict(value=1.0)), ("constant", dict(value=2.0)), ("constant", dict(value=3.0)), ("constant", dict(value=4.0)), ("constant", dict(value=5.0)), ] ) add_field_from_function(grid, "z", functions, at=at) assert_array_almost_equal(grid[at]["z"], 15.0)
def test_add_field_from_function_constant_as_dict(at): grid = RasterModelGrid((20, 30)) add_field_from_function(grid, "z", {"constant": dict(value=10.0)}, at=at) assert_array_almost_equal(grid[at]["z"], 10.0)
def test_add_field_from_function_constant(at, to_list): grid = RasterModelGrid((20, 30)) function = to_list(("constant", dict(value=1.0))) add_field_from_function(grid, "z", function, at=at) assert_array_almost_equal(grid[at]["z"], 1.0)