temporary_level
full name: tenpy.tools.optimization.temporary_level
parent module:
tenpy.tools.optimization
type: class
Inheritance Diagram
Methods
|
- class tenpy.tools.optimization.temporary_level(temporary_level)[source]
Bases:
object
Context manager to temporarily set the optimization level to a different value.
- Parameters:
temporary_level (int | OptimizationFlag | str | None) – The optimization level to be set during the context. None defaults to the current value of the optimization level.
- temporary_level
The optimization level to be set during the context.
- Type:
None | OptimizationFlag
- _old_level
Optimization level to be restored at the end of the context manager.
- Type:
Examples
It is recommended to use this context manager in a
with
statement:# optimization level default with temporary_level(OptimizationFlag.safe): do_some_stuff() # temporarily have Optimization level `safe` # you can even change the optimization level to something else: set_level(OptimizationFlag.skip_args_check) do_some_really_heavy_stuff() # here we are back to the optimization level as before the ``with ...`` statement