Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.1 # must match uv.lock
hooks:
- id: ruff
- id: ruff-check
- id: ruff-format
5 changes: 5 additions & 0 deletions stubs/pandapower-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ class SupportsGeoInterface(Protocol):
def __geo_interface__(self) -> dict[str, Any]: ... # values are arbitrary

ConvertibleToCRS: TypeAlias = str | int | tuple[str, str] | list[str] | dict[str, Any] | SupportsToWkt

from pandapower.auxiliary import pandapowerNet # noqa: E402

class RunPPFunc(Protocol):
def __call__(self, net: pandapowerNet, *, calculate_voltage_angles: bool, **kwargs) -> object: ...
22 changes: 10 additions & 12 deletions stubs/pandapower-stubs/auxiliary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import pandas as pd
from numpy.typing import ArrayLike, DTypeLike, NDArray
from shapely.geometry.base import BaseGeometry

from pandapower._typing import Float, Int
from pandapower._typing import Array2D, Float, Int
from pandapower.std_types import _StdTypes

_T = TypeVar("_T")
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")

def log_to_level(msg: str, passed_logger: logging.Logger, level: str) -> None: ...
def version_check(package_name: str, level="UserWarning", ignore_not_installed: bool = False) -> None: ...
def version_check(package_name: str, level: str = "UserWarning", ignore_not_installed: bool = False) -> None: ...
def soft_dependency_error(fct_name: str, required_packages: str | Iterable[str]) -> NoReturn: ...
def warn_and_fix_parameter_renaming(
old_parameter_name: str,
Expand All @@ -28,14 +26,14 @@ def warn_and_fix_parameter_renaming(
**kwargs: Any,
) -> _T: ...

class ADict(dict[_KT, _VT], MutableMapping[_KT, _VT]):
def __setattr__(self, key: str, value: _VT) -> None: ...
def __delattr__(self, key: _KT, force: bool = False) -> None: ... # type: ignore[override]
def __call__(self, key: _KT) -> _VT: ...
def __getattr__(self, name: str) -> _VT: ...
class ADict(dict[str, _T], MutableMapping[str, _T]):
def __setattr__(self, key: str, value: _T) -> None: ...
def __delattr__(self, key: str, force: bool = False) -> None: ...
def __call__(self, key: str) -> _T: ...
def __getattr__(self, key: str) -> _T: ...
def __deepcopy__(self, memo: dict[int, Any] | None) -> Self: ...

class pandapowerNet(ADict[str, pd.DataFrame]):
class pandapowerNet(ADict[pd.DataFrame]):
# These attributes are not defined in the class body, but are added via __getitem__
bus: pd.DataFrame
bus_dc: pd.DataFrame
Expand Down Expand Up @@ -197,8 +195,8 @@ def phase_shift_unit_operator(angle_deg: Float) -> np.complex128: ...

a: Final[np.complex128]
asq: Final[np.complex128]
Tabc: Final[np.ndarray[tuple[int, int], np.dtype[np.complex128]]]
T012: Final[np.ndarray[tuple[int, int], np.dtype[np.complex128]]]
Tabc: Final[Array2D[np.complex128]]
T012: Final[Array2D[np.complex128]]

def sequence_to_phase(X012: ArrayLike) -> NDArray[np.complex128]: ...
def phase_to_sequence(Xabc: ArrayLike) -> NDArray[np.complex128]: ...
Expand Down
42 changes: 31 additions & 11 deletions stubs/pandapower-stubs/build_bus.pyi
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
from _typeshed import Incomplete
from typing import TypeVar
from collections.abc import Collection
from typing import Literal, TypeVar

import numpy as np
from numpy.typing import NDArray

from pandapower._typing import Array1D, Bool, Float, Int, ScalarOrVector
from pandapower.auxiliary import pandapowerNet

_T = TypeVar("_T")

def ds_find(ar, bus): ...
def ds_union(ar, bus1, bus2, bus_is_pv) -> None: ...
def ds_create(ar, switch_bus, switch_elm, switch_et_bus, switch_closed, switch_z_ohm, bus_is_pv, bus_in_service) -> None: ...
def fill_bus_lookup(ar, bus_lookup, bus_index) -> None: ...
def create_bus_lookup_numba(net: pandapowerNet, bus_index, bus_is_idx, gen_is_mask, eg_is_mask) -> NDArray[np.int_]: ...
def ds_union(ar, bus1: Int, bus2: Int, bus_is_pv, bus_is_active, merged_bus) -> None: ...
def ds_create(
ar,
switch_bus: Collection[Int],
switch_elm: Collection[Int],
switch_et_bus: Collection[Int],
switch_closed: Collection[Bool],
switch_z_ohm: Collection[Float],
bus_is_pv,
bus_is_active,
bus_in_service,
merged_bus,
) -> None: ...
def fill_bus_lookup(ar, bus_lookup, bus_index: Collection[Int]) -> None: ...
def create_bus_lookup_numba(
net: pandapowerNet, bus_index: Collection[Int], bus_is_idx: ScalarOrVector[Int]
) -> tuple[Array1D[np.int64], Array1D[np.bool]]: ...

class DisjointSet(dict[_T, _T]):
def add(self, item: _T) -> None: ...
def find(self, item: _T) -> _T: ...
def union(self, item1: _T, item2: _T) -> None: ...

def create_consecutive_bus_lookup(net: pandapowerNet, bus_index): ...
def create_consecutive_bus_lookup(net: pandapowerNet, bus_index: Collection[Int]) -> Array1D[np.int64]: ...
def create_bus_lookup_numpy(
net: pandapowerNet, bus_index, bus_is_idx, gen_is_mask, eg_is_mask, closed_bb_switch_mask
) -> NDArray[np.int_]: ...
def create_bus_lookup(net: pandapowerNet, bus_index, bus_is_idx, gen_is_mask, eg_is_mask, numba: bool) -> NDArray[np.int_]: ...
def get_voltage_init_vector(net: pandapowerNet, init_v, mode, sequence: Incomplete | None = None): ...
def set_reference_buses(net: pandapowerNet, ppc, bus_lookup, mode) -> None: ...
net: pandapowerNet, bus_index: Collection[Int], closed_bb_switch_mask: NDArray[np.bool]
) -> tuple[Array1D[np.int64], Array1D[np.bool]]: ...
def create_bus_lookup(
net: pandapowerNet, bus_index: Collection[Int], bus_is_idx: ScalarOrVector[Int], numba: Bool
) -> tuple[Array1D[np.int64], Array1D[np.bool]]: ...
def get_voltage_init_vector(
net: pandapowerNet, init_v, mode: Literal["magnitude", "angle"], sequence: Incomplete | None = None
): ...
def set_reference_buses(net: pandapowerNet, ppc, bus_lookup, mode: str) -> None: ...
def set_reference_buses_dc(net: pandapowerNet, ppc, bus_lookup, mode: str) -> None: ...
59 changes: 36 additions & 23 deletions stubs/pandapower-stubs/grid_equivalents/auxiliary.pyi
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
from _typeshed import Incomplete
from _typeshed import SupportsGetItem
from collections.abc import Collection, Iterable
from typing import TypeVar

home: Incomplete
desktop: Incomplete
import pandas as pd

from pandapower._typing import Bool, Int, RunPPFunc
from pandapower.auxiliary import pandapowerNet

_S = TypeVar("_S", tuple[Int, ...], list[Int])

impedance_columns: list[str]

def add_ext_grids_to_boundaries(
net,
boundary_buses,
adapt_va_degree: bool = False,
runpp_fct=...,
calc_volt_angles: bool = True,
allow_net_change_for_convergence: bool = False,
net: pandapowerNet,
boundary_buses: Iterable[Int],
adapt_va_degree: Bool = False,
runpp_fct: RunPPFunc = ...,
calc_volt_angles: Bool = True,
allow_net_change_for_convergence: Bool = False,
) -> pd.Index[int]: ...
def drop_internal_branch_elements(
net: pandapowerNet, internal_buses: Collection[Int], branch_elements: Iterable[Int] | None = None
) -> None: ...
def calc_zpbn_parameters(
net: pandapowerNet, boundary_buses: _S, all_external_buses: _S, slack_as: str = "gen", existing_shift_degree: Bool = False
) -> tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame]: ...
def drop_assist_elms_by_creating_ext_net(net: pandapowerNet, elms: Iterable[str] | None = None) -> None: ...
def build_ppc_and_Ybus(net: pandapowerNet) -> None: ...
def drop_measurements_and_controllers(net: pandapowerNet, buses: Collection[Int], skip_controller: Bool = False) -> None: ...
def ensure_origin_id(net: pandapowerNet, elms: Iterable[str] | None = None) -> None: ...
def drop_and_edit_cost_functions(
net: pandapowerNet, buses: Collection[Int], drop_cost: Bool, add_origin_id: Bool, check_unique_elms_name: Bool = True
) -> None: ...
def drop_internal_branch_elements(net, internal_buses, branch_elements: Incomplete | None = None) -> None: ...
def calc_zpbn_parameters(net, boundary_buses, all_external_buses, slack_as: str = "gen", existing_shift_degree: bool = False): ...
def check_validity_of_Ybus_eq(net_zpbn, Ybus_eq, bus_lookups): ...
def drop_assist_elms_by_creating_ext_net(net, elms: Incomplete | None = None) -> None: ...
def build_ppc_and_Ybus(net) -> None: ...
def drop_measurements_and_controller(net, buses, skip_controller: bool = False) -> None: ...
def match_controller_and_new_elements(net, net_org) -> None: ...
def ensure_origin_id(net, no_start: int = 0, elms: Incomplete | None = None) -> None: ...
def drop_and_edit_cost_functions(net, buses, drop_cost, add_origin_id, check_unique_elms_name: bool = True) -> None: ...
def match_cost_functions_and_eq_net(net, boundary_buses, eq_type) -> None: ...
def check_network(net) -> None: ...
def get_boundary_vp(net_eq, bus_lookups): ...
def adaptation_phase_shifter(net, v_boundary, p_boundary): ...
def replace_motor_by_load(net, all_external_buses) -> None: ...
def match_cost_functions_and_eq_net(net: pandapowerNet, boundary_buses: Iterable[Int], eq_type: str) -> None: ...
def get_boundary_vp(
net_eq: pandapowerNet, bus_lookups: SupportsGetItem[str, SupportsGetItem[str, Collection[Int]]]
) -> tuple[pd.DataFrame, pd.DataFrame]: ...
def adaptation_phase_shifter(net: pandapowerNet, v_boundary: pd.DataFrame, p_boundary: pd.DataFrame) -> pandapowerNet: ...
def replace_motor_by_load(net: pandapowerNet, all_external_buses: Collection[Int]) -> None: ...
34 changes: 20 additions & 14 deletions stubs/pandapower-stubs/grid_equivalents/get_equivalent.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from collections.abc import Collection
from typing import Literal

from pandapower._typing import Bool, Int, RunPPFunc
from pandapower.auxiliary import pandapowerNet

def get_equivalent(
net,
eq_type,
boundary_buses,
internal_buses,
return_internal: bool = True,
show_computing_time: bool = False,
net: pandapowerNet,
eq_type: Literal["rei", "ward", "xward"],
boundary_buses: Collection[Int],
internal_buses: Collection[Int],
return_internal: Bool = True,
show_computing_time: Bool = False,
ward_type: str = "ward_injection",
adapt_va_degree: bool = False,
calculate_voltage_angles: bool = True,
allow_net_change_for_convergence: bool = False,
runpp_fct=...,
adapt_va_degree: Bool = False,
calculate_voltage_angles: Bool = True,
allow_net_change_for_convergence: Bool = False,
runpp_fct: RunPPFunc = ...,
**kwargs,
): ...
) -> pandapowerNet | None: ...
def merge_internal_net_and_equivalent_external_net(
net_eq, net_internal, eq_type, show_computing_time: bool = False, calc_volt_angles: bool = False, **kwargs
): ...
def drop_repeated_characteristic(net) -> None: ...
net_eq: pandapowerNet, net_internal: pandapowerNet, fuse_bus_column: str = "auto", show_computing_time: bool = False, **kwargs
) -> pandapowerNet: ...
def drop_repeated_characteristic(net: pandapowerNet) -> None: ...
13 changes: 12 additions & 1 deletion stubs/pandapower-stubs/grid_equivalents/rei_generation.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
def adapt_impedance_params(Z, sign: int = 1, adaption: float = 1e-15): ...
from typing import TypeVar, overload

import numpy as np

_S = TypeVar("_S", bound=tuple[int, ...])

@overload
def adapt_impedance_params(Z: complex, sign: int = 1, adaption: float = 1e-15) -> float: ...
@overload
def adapt_impedance_params(
Z: np.ndarray[_S, np.dtype[np.complexfloating]], sign: int = 1, adaption: float = 1e-15
) -> np.ndarray[_S, np.dtype[np.float64]]: ...
16 changes: 13 additions & 3 deletions stubs/pandapower-stubs/grid_equivalents/toolbox.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
from _typeshed import SupportsKeysAndGetItem
from collections.abc import Collection, Iterable

from pandapower._typing import Int
from pandapower.auxiliary import pandapowerNet

def getFromDict(dict_, keys): ...
def setInDict(dict_, keys, value) -> None: ...
def appendSetInDict(dict_, keys, set_) -> None: ...
def setSetInDict(dict_, keys, set_) -> None: ...
def append_set_to_dict(dict_, set_, keys) -> None: ...
def set_bus_zone_by_boundary_branches(net, all_boundary_branches) -> None: ...
def get_boundaries_by_bus_zone_with_boundary_branches(net): ...
def get_connected_switch_buses_groups(net, buses): ...
def set_bus_zone_by_boundary_branches(
net: pandapowerNet, all_boundary_branches: SupportsKeysAndGetItem[str, Collection[Int]]
) -> None: ...
def get_boundaries_by_bus_zone_with_boundary_branches(
net: pandapowerNet,
) -> tuple[dict[str, dict[str, set[int]]], dict[str, dict[str, set[int]]]]: ...
def get_connected_switch_buses_groups(net: pandapowerNet, buses: Iterable[Int]) -> tuple[set[int], list[list[int]]]: ...
15 changes: 12 additions & 3 deletions stubs/pandapower-stubs/grid_equivalents/ward_generation.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
def create_passive_external_net_for_ward_addmittance(
net, all_external_buses, boundary_buses, calc_volt_angles: bool = ..., runpp_fct=...
from collections.abc import Collection

from pandapower._typing import Bool, Int, RunPPFunc
from pandapower.auxiliary import pandapowerNet

def create_passive_external_net_for_ward_admittance(
net: pandapowerNet,
all_external_buses: Collection[Int],
boundary_buses: Collection[Int] | object, # not used!
calc_volt_angles: Bool = True,
runpp_fct: RunPPFunc = ...,
**kwargs,
) -> None: ...
def get_ppc_buses(net, buses, nogo_buses): ...
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/io_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class JSONSerializableClass:
overwrite: bool = False,
preserve_dtypes: bool = False,
fill_dict: dict[str, Any] | None = None,
) -> int: ...
) -> np.int64: ...
def equals(self, other: object) -> bool: ...
@classmethod
def from_dict(cls, d: dict[str, object]) -> Self: ...
Expand Down
18 changes: 18 additions & 0 deletions stubs/pandapower-stubs/pf/create_jacobian_facts.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Final

from scipy.sparse import csr_array, csr_matrix # type: ignore[import-untyped]

SMALL_NUMBER: Final = 1e-9

def create_J_modification_svc(
J, svc_buses, pvpq, pq, pq_lookup, Vm, x_control, svc_x_l_pu, svc_x_cvar_pu, nsvc_controllable, svc_controllable
) -> csr_matrix: ...
def create_J_modification_tcsc(
J, V, y_tcsc_pu, x_control, tcsc_controllable, tcsc_x_l_pu, f, t, pvpq, pq, pvpq_lookup, pq_lookup, nsvc
) -> csr_matrix: ...
def create_J_modification_ssc_vsc(
J, V, Vm, y_pu, f, t, pvpq, pq, pvpq_lookup, pq_lookup, control_v, control_delta
) -> csr_matrix: ...
def create_J_modification_hvdc(
J, V_dc, Ybus_hvdc, Ybus_vsc_dc, vsc_g_pu, vsc_gl_pu, dc_p, dc_p_lookup, vsc_dc_fb, vsc_dc_tb, vsc_dc_slack, vsc_dc_mode_p
) -> csr_array: ...
8 changes: 5 additions & 3 deletions stubs/pandapower-stubs/pf/dSbus_dV_numba.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from _typeshed import Incomplete
from typing import TypeVar

def dSbus_dV_numba_sparse(Yx, Yp, Yj, V, Vnorm, Ibus): ...
def dSbus_dV(Ybus, V, I: Incomplete | None = None): ...
_YxT = TypeVar("_YxT") # probably bound to ndarray

def dSbus_dV_numba_sparse(Yx: _YxT, Yp, Yj, V, Vnorm, Ibus) -> tuple[_YxT, _YxT]: ...
def dSbus_dV(Ybus, V, I=None): ...
12 changes: 12 additions & 0 deletions stubs/pandapower-stubs/pf/makeYbus_facts.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from scipy.sparse import csr_matrix # type: ignore[import-untyped]

from pandapower._typing import Float, Int

def calc_y_svc(x_control_degree, svc_x_l_ohm, svc_x_cvar_ohm, v_base_kv, baseMVA: Float): ...
def calc_y_svc_pu(x_control, svc_x_l_pu, svc_x_cvar_pu): ...
def makeYbus_svc(Ybus, x_control_svc, svc_x_l_pu, svc_x_cvar_pu, svc_buses) -> csr_matrix: ...
def makeYbus_tcsc(Ybus, x_control_tcsc, tcsc_x_l_pu, tcsc_x_cvar_pu, tcsc_fb, tcsc_tb) -> csr_matrix: ...
def makeYft_tcsc(Ybus_tcsc, tcsc_fb, tcsc_tb, x_control_tcsc, tcsc_x_l_pu, tcsc_x_cvar_pu) -> tuple[csr_matrix, csr_matrix]: ...
def makeYbus_ssc_vsc(Ybus, internal_y_pu, fb, tb, controllable) -> tuple[csr_matrix, csr_matrix, csr_matrix]: ...
def make_Ybus_facts(from_bus, to_bus, y_pu, n: Int, ysf_pu=0, yst_pu=0, dtype=...) -> csr_matrix: ...
def make_Yft_facts(from_bus, to_bus, y_pu, n: Int, ysf_pu=0, yst_pu=0) -> tuple[csr_matrix, csr_matrix]: ...
11 changes: 9 additions & 2 deletions stubs/pandapower-stubs/pf/makeYbus_numba.pyi
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
def gen_Ybus(Yf_x, Yt_x, Ysh, col_Y, f, t, f_sort, t_sort, nb, nl, r_nl): ...
def makeYbus(baseMVA, bus, branch): ...
import numpy as np
from scipy.sparse import csr_array, csr_matrix # type: ignore[import-untyped]

from pandapower._typing import Array1D, Float, Int

def gen_Ybus(
Yf_x, Yt_x, Ysh, col_Y, f, t, f_sort, t_sort, nb: Int, nl: Int, r_nl
) -> tuple[Array1D[np.complex128], Array1D[np.int64], Array1D[np.int64], int]: ...
def makeYbus(baseMVA: Float, bus, branch) -> tuple[csr_matrix, csr_array, csr_array]: ...
Loading