pypsa.statistics.StatisticsAccessor.curtailment

pypsa.statistics.StatisticsAccessor.curtailment#

StatisticsAccessor.curtailment#

Decorator to wrap a method with a handler class.

This decorator wraps any method with a handler class that is used to process the method’s return value. The handler class must be a callable with the same signature as the method to guarantee compatibility. It also must be initialized with the method as its first argument. If so, the API is only extended and not changed. The handler class can be used as a drop-in replacement for the method.

Needs to be used as a callable decorator, i.e. with parentheses: >>> class MyHandlerClass: … def __init__(self, bound_method: Callable) -> None: … self.bound_method = bound_method … def __call__(self, *args: Any, **kwargs: Any) -> pd.DataFrame: … return self.bound_method(*args, **kwargs)

>>> @MethodHandlerWrapper(handler_class=MyHandlerClass)
... def my_method(self, *args, **kwargs):
...     pass