landlab.core.model_parameter_loader

load_file_contents(file_like)[source]

Load the contents of a file or file-like object.

Parameters:

file_like (file_like or str) – File to load either as a file-like object, path to an existing file, or the contents of a file.

Returns:

The contents of the file.

Return type:

str

load_params(file_like)[source]

Load parameters from a YAML style file.

Parameters:

file_like (file_like or str) – Contents of a parameter file, a file-like object, or the path to a parameter file.

Returns:

Parameters as key-value pairs.

Return type:

dict

Examples

>>> from landlab.core import load_params
>>> contents = '''
... start: 0.
... stop: 10.
... step: 2.
... '''
>>> params = load_params(contents)
>>> isinstance(params, dict)
True
>>> params["start"], params["stop"], params["step"]
(0.0, 10.0, 2.0)