pypsa.option_context

Contents

pypsa.option_context#

pypsa.option_context(*args: Any) Generator[None, None, None]#

Context manager to temporarily set options.

Parameters:

*args (str, Any) – Must be passed in pairs of option_name and value. Option_name must be in the format “category.option_name”

Return type:

None

See also

get_option

Get value for option

set_option

Set value for option

describe_options

Print documentation for all options

Examples

>>> import pypsa
>>> with pypsa.option_context("warnings.components_store_iter", False):
...     # do something with temporary option value
...     print(pypsa.get_option("warnings.components_store_iter"))
False
>>> # options are reverted to original values
>>> print(pypsa.get_option("warnings.components_store_iter"))
True