Skip to content

Commit

Permalink
Update pp control and timeseries
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdanal committed Dec 29, 2024
1 parent 3e22976 commit 7c156cf
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 77 deletions.
73 changes: 42 additions & 31 deletions stubs/pandapower-stubs/control/basic_controller.pyi
Original file line number Diff line number Diff line change
@@ -1,48 +1,59 @@
from _typeshed import Incomplete
from typing import Any, SupportsIndex as Int

from pandapower.auxiliary import pandapowerNet
from pandapower.io_utils import JSONSerializableClass

class BasicCtrl(JSONSerializableClass):
index: Incomplete
def __init__(self, container, index: Incomplete | None = None, **kwargs) -> None: ...
def time_step(self, container, time) -> None: ...
def initialize_control(self, container) -> None: ...
def is_converged(self, container): ...
def control_step(self, container) -> None: ...
def repair_control(self, container) -> None: ...
def restore_init_state(self, container) -> None: ...
def finalize_control(self, container) -> None: ...
def finalize_step(self, container, time) -> None: ...
def set_active(self, container, in_service) -> None: ...
index: int
def __init__(self, container: pandapowerNet, index: Int | None = None, **kwargs) -> None: ...
def time_step(self, container: pandapowerNet, time: Any) -> None: ...
def initialize_control(self, container: pandapowerNet) -> None: ...
def is_converged(self, container: pandapowerNet): ...
def control_step(self, container: pandapowerNet) -> None: ...
def repair_control(self, container: pandapowerNet) -> None: ...
def restore_init_state(self, container: pandapowerNet) -> None: ...
def finalize_control(self, container: pandapowerNet) -> None: ...
def finalize_step(self, container: pandapowerNet, time: Any) -> None: ...
def set_active(self, container: pandapowerNet, in_service: bool) -> None: ...
def level_reset(self, prosumer) -> None: ...

class Controller(BasicCtrl):
matching_params: Incomplete
index: Incomplete
matching_params: dict[str, Any]
index: int
def __init__(
self,
net,
net: pandapowerNet,
in_service: bool = True,
order: int = 0,
level: int = 0,
index: Incomplete | None = None,
order: Int = 0,
level: Int = 0,
index: Int | None = None,
recycle: bool = False,
drop_same_existing_ctrl: bool = False,
initial_run: bool = True,
overwrite: bool = False,
matching_params: Incomplete | None = None,
matching_params: dict[str, Any] | None = None,
**kwargs,
) -> None: ...
def add_controller_to_net(
self, net, in_service, initial_run, order, level, index, recycle, drop_same_existing_ctrl, overwrite, **kwargs
): ...
def time_step(self, net, time) -> None: ...
def initialize_control(self, net) -> None: ...
def is_converged(self, net): ...
def control_step(self, net) -> None: ...
def repair_control(self, net) -> None: ...
def restore_init_state(self, net) -> None: ...
def finalize_control(self, net) -> None: ...
def finalize_step(self, net, time) -> None: ...
def set_active(self, net, in_service) -> None: ...
def set_recycle(self, net) -> None: ...
self,
net: pandapowerNet,
in_service: bool,
initial_run: bool,
order: Int,
level: Int,
index: Int,
recycle: bool,
drop_same_existing_ctrl: bool,
overwrite: bool,
**kwargs,
) -> int: ...
def time_step(self, net: pandapowerNet, time: Any) -> None: ...
def initialize_control(self, net: pandapowerNet) -> None: ...
def is_converged(self, net: pandapowerNet): ...
def control_step(self, net: pandapowerNet) -> None: ...
def repair_control(self, net: pandapowerNet) -> None: ...
def restore_init_state(self, net: pandapowerNet) -> None: ...
def finalize_control(self, net: pandapowerNet) -> None: ...
def finalize_step(self, net: pandapowerNet, time: Any) -> None: ...
def set_active(self, net: pandapowerNet, in_service: bool) -> None: ...
def set_recycle(self, net: pandapowerNet) -> None: ...
45 changes: 25 additions & 20 deletions stubs/pandapower-stubs/control/controller/const_control.pyi
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from typing import Any, SupportsIndex as Int

from pandas._typing import Axes, Scalar

from pandapower.auxiliary import pandapowerNet
from pandapower.control.basic_controller import Controller
from pandapower.timeseries.data_source import DataSource

class ConstControl(Controller):
data_source: Incomplete
element_index: Incomplete
element: Incomplete
values: Incomplete
profile_name: Incomplete
scale_factor: Incomplete
data_source: DataSource
element_index: Axes | Scalar
element: str
values: Any
profile_name: str | Iterable[str]
scale_factor: float
applied: bool
def __init__(
self,
net,
element,
variable,
element_index,
profile_name: Incomplete | None = None,
data_source: Incomplete | None = None,
net: pandapowerNet,
element: str,
variable: str,
element_index: Axes | Scalar,
profile_name: str | Iterable[str] | None = None,
data_source: DataSource | None = None,
scale_factor: float = 1.0,
in_service: bool = True,
recycle: bool = True,
order: int = -1,
level: int = -1,
order: Int = -1,
level: Int = -1,
drop_same_existing_ctrl: bool = False,
matching_params: Incomplete | None = None,
matching_params: dict[str, Any] | None = None,
initial_run: bool = False,
**kwargs,
) -> None: ...
def set_recycle(self, net) -> None: ...
def time_step(self, net, time) -> None: ...
def is_converged(self, net): ...
def control_step(self, net) -> None: ...
def set_recycle(self, net: pandapowerNet) -> None: ...
def time_step(self, net: pandapowerNet, time: Any) -> None: ...
def is_converged(self, net: pandapowerNet) -> bool: ...
def control_step(self, net: pandapowerNet) -> None: ...
6 changes: 3 additions & 3 deletions stubs/pandapower-stubs/io_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import json
from _typeshed import Incomplete, ReadableBuffer, StrOrBytesPath, SupportsRead
from collections.abc import Callable, Container, Mapping
from functools import singledispatch
from typing import Any, TypeVar
from typing import Any, SupportsIndex as Int, TypeVar
from typing_extensions import Self

import pandas as pd
Expand Down Expand Up @@ -106,11 +106,11 @@ class JSONSerializableClass:
self,
net: pandapowerNet,
element: str,
index: int | None = None,
index: Int | None = None,
column: str = "object",
overwrite: bool = False,
preserve_dtypes: bool = False,
fill_dict: dict[str, Incomplete] | None = None,
fill_dict: dict[str, Any] | None = None,
) -> int: ...
def equals(self, other: object) -> bool: ...
@classmethod
Expand Down
7 changes: 5 additions & 2 deletions stubs/pandapower-stubs/timeseries/data_source.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from typing import Any

from pandas._typing import Scalar

from pandapower.io_utils import JSONSerializableClass

class DataSource(JSONSerializableClass):
def get_time_step_value(self, time_step: Incomplete, profile_name: str, scale_factor: float = 1.0) -> Incomplete: ...
def get_time_step_value(self, time_step: Scalar, profile_name: str | Iterable[str], scale_factor: float = 1.0) -> Any: ...
14 changes: 9 additions & 5 deletions stubs/pandapower-stubs/timeseries/data_sources/frame_data.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from typing import Any

import pandas as pd
from pandas._typing import Scalar

from pandapower.timeseries.data_source import DataSource

class DFData(DataSource):
df: Incomplete
def __init__(self, df, multi: bool = False) -> None: ...
def get_time_step_value(self, time_step, profile_name, scale_factor: float = 1.0): ...
def get_time_steps_len(self): ...
df: pd.DataFrame
def __init__(self, df: pd.DataFrame, multi: bool = False) -> None: ...
def get_time_step_value(self, time_step: Scalar, profile_name: str | Iterable[str], scale_factor: float = 1.0) -> Any: ...
def get_time_steps_len(self) -> int: ...
7 changes: 3 additions & 4 deletions stubs/pandapower-stubs/timeseries/output_writer.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from _typeshed import Incomplete
from collections.abc import Callable, Mapping, Sequence
from functools import partial
from typing import Generic, Literal, TypeVar
from typing import Any, Generic, Literal

import pandas as pd
from numpy.typing import NDArray
from pandas._typing import S1 as _T

from pandapower.auxiliary import pandapowerNet
from pandapower.io_utils import JSONSerializableClass

_T = TypeVar("_T")

class OutputWriter(JSONSerializableClass, Generic[_T]):
output_path: str | None
output_file_type: Literal[".xls", ".xlsx", ".csv", ".p", ".json"]
Expand All @@ -30,7 +29,7 @@ class OutputWriter(JSONSerializableClass, Generic[_T]):
def __init__(
self,
net: pandapowerNet,
time_steps: Sequence[_T] | None = None,
time_steps: Sequence[_T] | pd.Index[_T] | pd.Series[_T] | NDArray[Any] | None = None,
output_path: str | None = None,
output_file_type: Literal[".xls", ".xlsx", ".csv", ".p", ".json"] = ".p",
write_time: float | None = None,
Expand Down
31 changes: 19 additions & 12 deletions stubs/pandapower-stubs/timeseries/run_time_series.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete, Unused
from _typeshed import Incomplete, SupportsGetItem, Unused
from collections.abc import Callable, Iterable, Mapping
from typing import Any, Literal, TypeVar, overload

Expand All @@ -7,26 +7,28 @@ from pandapower.auxiliary import pandapowerNet
_T = TypeVar("_T")

def init_default_outputwriter(net: pandapowerNet, time_steps: Iterable[Incomplete]) -> None: ...
def init_output_writer(net: pandapowerNet, time_steps: Incomplete) -> None: ...
def controller_not_converged(time_step: object, ts_variables: Mapping[str, Any]) -> None: ...
def pf_not_converged(time_step: object, ts_variables: Mapping[str, Any]) -> None: ...
def control_time_step(controller_order: Iterable[Incomplete], time_step: Incomplete) -> None: ...
def finalize_step(controller_order: Iterable[Incomplete], time_step: Incomplete) -> None: ...
def init_output_writer(net: pandapowerNet, time_steps) -> None: ...
def controller_not_converged(time_step: object, ts_variables: SupportsGetItem[str, Any]) -> None: ...
def pf_not_converged(time_step: object, ts_variables: SupportsGetItem[str, Any]) -> None: ...
def control_time_step(controller_order: Iterable[Iterable[tuple[Incomplete, pandapowerNet]]], time_step) -> None: ...
def finalize_step(controller_order: Iterable[Iterable[tuple[Incomplete, pandapowerNet]]], time_step) -> None: ...
def output_writer_routine(
net: pandapowerNet, time_step: Incomplete, pf_converged: bool, ctrl_converged: bool, recycle_options: Mapping[str, Any]
net: pandapowerNet, time_step, pf_converged: bool, ctrl_converged: bool, recycle_options: Mapping[str, Any]
) -> None: ...
def run_time_step(
net: pandapowerNet,
time_step: Incomplete,
time_step,
ts_variables: dict[str, Incomplete],
run_control_fct: Callable[..., object] = ...,
output_writer_fct: Callable[[pandapowerNet, Incomplete, bool, bool, dict[str, Incomplete]], object] = ...,
**kwargs,
) -> None: ...
@overload
def get_recycle_settings(net: pandapowerNet, recycle: Literal[False], **kwargs: Unused) -> Literal[False]: ...
def get_recycle_settings(net: pandapowerNet, *, recycle: Literal[False], **kwargs: Unused) -> Literal[False]: ...
@overload
def get_recycle_settings(net: pandapowerNet, **kwargs: Incomplete) -> dict[str, Any] | Literal[False]: ...
def get_recycle_settings(
net: pandapowerNet, *, recycle: Incomplete | None = None, **kwargs
) -> dict[str, Any] | Literal[False]: ...
@overload
def init_time_steps(net: pandapowerNet, time_steps: Iterable[_T], **kwargs: Unused) -> Iterable[_T]: ... # type: ignore[overload-overlap]
@overload
Expand All @@ -41,7 +43,7 @@ def init_time_series(
**kwargs,
) -> dict[str, Any]: ...
def cleanup(net: pandapowerNet, ts_variables: dict[str, Incomplete]) -> None: ...
def print_progress(i: int, time_step: Incomplete, time_steps: Incomplete, verbose: bool, **kwargs: Incomplete) -> None: ...
def print_progress(i: int, time_step, time_steps, verbose: bool, **kwargs) -> None: ...
def run_loop(
net: pandapowerNet,
ts_variables: dict[str, Incomplete],
Expand All @@ -50,5 +52,10 @@ def run_loop(
**kwargs,
) -> None: ...
def run_timeseries(
net: pandapowerNet, time_steps: Incomplete | None = None, continue_on_divergence: bool = False, verbose: bool = True, **kwargs
net: pandapowerNet,
time_steps: Incomplete | None = None,
continue_on_divergence: bool = False,
verbose: bool = True,
check_controllers: bool = True,
**kwargs,
) -> None: ...

0 comments on commit 7c156cf

Please sign in to comment.