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
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ repos:
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-case-conflict
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.17
hooks:
- id: uv-lock
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.11 # must match uv.lock
rev: v0.15.15 # must match uv.lock
hooks:
- id: ruff-check
- id: ruff-format
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ This project is licensed under the MIT License.
<th>Import name</th>
<th>Links</th>
<th>Status</th>
<th>Type-checked</th>
<th>Tested</th>
</tr>
<tr>
Expand All @@ -56,7 +55,6 @@ This project is licensed under the MIT License.
<a href="https://github.com/jimfunk/django-postgresql-netfields">GitHub</a>
</th>
<th>Complete</th>
<th>Yes</th>
<th>No</th>
</tr>
<tr>
Expand All @@ -67,7 +65,6 @@ This project is licensed under the MIT License.
<a href="https://github.com/SectorLabs/django-postgres-extra">GitHub</a>
</th>
<th>Incomplete</th>
<th>Yes</th>
<th>No</th>
</tr>
<tr>
Expand All @@ -79,6 +76,15 @@ This project is licensed under the MIT License.
</th>
<th>Incomplete</th>
<th>Yes</th>
</tr>
<tr>
<th>pyogrio</th>
<th><code>pyogrio</code></th>
<th>
<a href="https://pypi.org/project/pyogrio">PyPI</a>,
<a href="https://github.com/geopandas/pyogrio">GitHub</a>
</th>
<th>Complete</th>
<th>Yes</th>
</tr>
</table>
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tests = [
"types-geopandas>=1.0.1",
"types-shapely>=2.0.0",
"pandas-stubs>=2.2.2",
"pyarrow-stubs>=20.0.0",
"matplotlib>=3.8.0",
"folium>=0.16.0",
"rtree>=1.2.0",
Expand All @@ -25,11 +26,11 @@ tests = [
"types-networkx>=3.4.2",
]
dev = [
"ruff>=0.14.14",
"pytest>=8.0",
"rich-argparse>=1.6.0",
"mypy[native-parser]>=1.20.1",
"pyright>=1.1.408",
"ruff>=0.15.15",
"pytest>=9.0",
"rich-argparse>=1.8.0",
"mypy[native-parser]>=2.1.0",
"pyright>=1.1.409",
{ include-group = "tests" },
]

Expand Down Expand Up @@ -85,8 +86,7 @@ warn_unused_ignores = true
disallow_untyped_defs = false
disallow_incomplete_defs = false
enable_error_code = "deprecated"
local_partial_types = true
allow_redefinition_new = true
allow_redefinition = true
native_parser = true

[tool.pyright]
Expand Down
8 changes: 5 additions & 3 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@
"ruff-format": ["tests", "stubs"],
"mypy": ["tests", "stubs"],
"pyright": ["tests", "stubs"],
"stubtest": ["--allowlist=stubtest_allowlist.txt", "pandapower"],
"stubtest": ["--allowlist=stubtest_allowlist.txt", "pandapower", "pyogrio"],
"pytest": [],
}
if (num_mypy_workers := min(os.cpu_count() or 1, 6)) > 1:
default_args["mypy"].insert(0, f"--num-workers={num_mypy_workers}")
del num_mypy_workers

_newl = "\n"
description = f"""\
Run project development tools with proper environment setup.

The following commands are available:

Command | Default invocation |
------- | ------------------ |
{_newl.join(f"{tool} | {l2c((*tool.split('-'), *default))}" for tool, default in default_args.items())}
{"\n".join(f"{tool} | {l2c((*tool.split('-'), *default))}" for tool, default in default_args.items())}

You can override the default invocation by passing extra args after the command.
"""
Expand Down
17 changes: 11 additions & 6 deletions stubs/pandapower-stubs/auxiliary.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from collections.abc import Iterable, Mapping, MutableMapping
from collections.abc import Collection, Iterable, Mapping, MutableMapping
from typing import Any, Final, Literal, NoReturn, Self, overload

import geopandas as gpd
Expand All @@ -8,7 +8,7 @@ import pandas as pd
from numpy.typing import ArrayLike, DTypeLike, NDArray
from shapely.geometry.base import BaseGeometry

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

def log_to_level(msg: str, passed_logger: logging.Logger, level: str) -> None: ...
Expand Down Expand Up @@ -137,18 +137,22 @@ class GeoAccessor:
def __getattr__(self, item: str) -> Any: ...

def plural_s(number: Int) -> str: ...

type EtType = Literal["b", "l", "t", "t3", "i"]
type ElementType = Literal["bus", "line", "trafo", "trafo3w", "impedance"]

@overload
def ets_to_element_types(ets: None = None) -> pd.Series[str]: ...
@overload
def ets_to_element_types(ets: str) -> str: ...
def ets_to_element_types(ets: EtType) -> ElementType: ...
@overload
def ets_to_element_types(ets: list[str] | pd.Series[str] | pd.Index[str] | NDArray[np.str_]) -> list[str]: ...
def ets_to_element_types(ets: list[str] | pd.Series[str] | pd.Index[str] | NDArray[np.str_]) -> list[ElementType]: ...
@overload
def element_types_to_ets(element_types: None = None) -> pd.Series[str]: ...
@overload
def element_types_to_ets(element_types: str) -> str: ...
def element_types_to_ets(element_types: ElementType) -> EtType: ...
@overload
def element_types_to_ets(element_types: list[str] | pd.Series[str] | pd.Index[str] | NDArray[np.str_]) -> list[str]: ...
def element_types_to_ets(element_types: list[str] | pd.Series[str] | pd.Index[str] | NDArray[np.str_]) -> list[EtType]: ...
def empty_defaults_per_dtype(dtype: DTypeLike) -> float | Literal[""] | None: ...
def get_free_id(df: pd.DataFrame) -> np.int64: ...

Expand Down Expand Up @@ -183,6 +187,7 @@ def write_to_net(
def get_values(source, selection, lookup) -> NDArray[np.int64]: ...
def set_elements_oos(ti, tis, bis, lis) -> None: ...
def set_isolated_buses_oos(bus_in_service, ppc_bus_isolated, bus_lookup) -> None: ...
def get_vsc_stacked_names(elements: Collection[str]) -> Array1D[np.str_]: ...
def X012_to_X0(X012: ArrayLike) -> NDArray[np.complex128]: ...
def X012_to_X1(X012: ArrayLike) -> NDArray[np.complex128]: ...
def X012_to_X2(X012: ArrayLike) -> NDArray[np.complex128]: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/build_branch.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pandapower.auxiliary import pandapowerNet

def get_trafo_values(trafo_df, par): ...
def get_trafo_values(trafo_df, column: str, na_replacement=...): ...
def get_is_lines(net: pandapowerNet) -> None: ...
def z_br_to_bus_vector(z, sn): ...
def wye_delta(zbr_n, s): ...
Expand Down
9 changes: 0 additions & 9 deletions stubs/pandapower-stubs/control/basic_controller.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,4 @@ class Controller(BasicCtrl):
overwrite: bool,
**kwargs,
) -> np.int64: ...
def time_step(self, net: pandapowerNet, time: Any) -> None: ...
def initialize_control(self, net: pandapowerNet) -> None: ...
def is_converged(self, net: pandapowerNet) -> bool | np.bool: ...
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: ...
2 changes: 0 additions & 2 deletions stubs/pandapower-stubs/converter/matpower/from_mpc.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
matpowercaseframes_imported: bool

def from_mpc(mpc_file, f_hz: int = 50, casename_mpc_file: str = "mpc", validate_conversion: bool = False, **kwargs): ...
3 changes: 3 additions & 0 deletions stubs/pandapower-stubs/create/load_create.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def create_asymmetric_load(
q_a_mvar: Float = 0,
q_b_mvar: Float = 0,
q_c_mvar: Float = 0,
sn_a_mva: Float = ...,
sn_b_mva: Float = ...,
sn_c_mva: Float = ...,
sn_mva: Float = ...,
name: str | None = None,
scaling: Float = 1.0,
Expand Down
7 changes: 5 additions & 2 deletions stubs/pandapower-stubs/create/sgen_create.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import numpy as np

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

def create_sgen(
net: pandapowerNet,
Expand Down Expand Up @@ -72,6 +72,9 @@ def create_asymmetric_sgen(
q_a_mvar: Float = 0,
q_b_mvar: Float = 0,
q_c_mvar: Float = 0,
sn_a_mva: Float = ...,
sn_b_mva: Float = ...,
sn_c_mva: Float = ...,
sn_mva: Float = ...,
name: str | None = None,
index: Int | None = None,
Expand All @@ -81,5 +84,5 @@ def create_asymmetric_sgen(
**kwargs,
) -> np.int64: ...
def create_sgen_from_cosphi(
net: pandapowerNet, bus: Int, sn_mva: Float, cos_phi: Float, mode: Literal["underexcited", "overexcited"], **kwargs
net: pandapowerNet, bus: Int, sn_mva: Float, cos_phi: Float, mode: UnderOverExcitedType, **kwargs
) -> np.int64: ...
11 changes: 5 additions & 6 deletions stubs/pandapower-stubs/create/shunt_create.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def create_ssc(
index: Int | None = None,
**kwargs,
) -> np.int64: ...
def create_b2b_vsc(
def create_vsc_stacked(
net: pandapowerNet,
bus: Int,
bus_dc_plus: Int,
Expand All @@ -101,7 +101,7 @@ def create_b2b_vsc(
index: Int | None = None,
**kwargs,
) -> np.int64: ...
def create_bi_vsc(
def create_vsc_bipolar(
net: pandapowerNet,
bus: Int,
bus_dc_plus: Int,
Expand All @@ -110,10 +110,9 @@ def create_bi_vsc(
x_ohm: Float,
r_dc_ohm: Float,
pl_dc_mw: Float = 0.0,
control_mode_ac: Literal["vm_pu", "q_mvar", "slack"] = "vm_pu",
control_value_ac: Float = 1.0,
control_mode_dc: Literal["vm_pu", "p_mw"] = "p_mw",
control_value_dc: Float = 0.0,
control_mode: Literal["vm_pu", "q_mvar", "slack", "Vac_phi"] = "Vac_phi",
control_value_1: Float = 1.0,
control_value_2: Float = 0.0,
name: str | None = None,
controllable: Bool = True,
in_service: Bool = True,
Expand Down
2 changes: 0 additions & 2 deletions stubs/pandapower-stubs/estimation/algorithm/lp.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from pandapower.estimation.algorithm.base import BaseAlgorithm
from pandapower.estimation.ppc_conversion import ExtendedPPCI

ortools_available: bool

class LPAlgorithm(BaseAlgorithm):
def estimate(self, eppci: ExtendedPPCI, with_ortools: bool = True, **kwargs): ...
3 changes: 0 additions & 3 deletions stubs/pandapower-stubs/file_io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ from typing import Any, overload

from pandapower.auxiliary import pandapowerNet

xlsxwriter_INSTALLED: bool
openpyxl_INSTALLED: bool

def to_pickle(net: pandapowerNet, filename: SupportsWrite[bytes] | str) -> None: ...
def to_excel(
net: pandapowerNet, filename: StrOrBytesPath, include_empty_tables: bool = False, include_results: bool = True
Expand Down
11 changes: 2 additions & 9 deletions stubs/pandapower-stubs/io_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ from shapely.geometry.base import BaseGeometry
from pandapower._typing import SupportsGeoInterface
from pandapower.auxiliary import pandapowerNet, pandapowerNet as _pandapowerNet

PSYCOPG2_INSTALLED: bool
cryptography_INSTALLED: bool
hashlib_INSTALLED: bool
base64_INSTALLED: bool
zlib_INSTALLED: bool
GEOPANDAS_INSTALLED: bool
SHAPELY_INSTALLED: bool

def coords_to_df(value: pd.DataFrame, geotype: str = "line") -> pd.DataFrame: ...
def to_dict_of_dfs(
net: pandapowerNet,
Expand Down Expand Up @@ -97,7 +89,8 @@ class FromSerializableRegistry:
def networkx(self) -> Incomplete: ...
def method(self) -> Incomplete: ...
def function(self) -> Incomplete: ...
def rest(self) -> Incomplete: ...
def bool_handling(self) -> bool: ...
def rest(self) -> Any: ...
def GeoDataFrame(self) -> gpd.GeoDataFrame: ...
def shapely(self) -> BaseGeometry: ...

Expand Down
5 changes: 2 additions & 3 deletions stubs/pandapower-stubs/pf/no_numba.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Callable

def jit[T](*args: Incomplete, **kwargs: Incomplete) -> Callable[[T], T]: ...
def marker(*args: Incomplete, **kwargs: Incomplete) -> Incomplete: ...
def jit[T](*args, **kwargs) -> Callable[[T], T]: ...
def marker(*args, **kwargs) -> Callable[..., object]: ...

int32 = marker
2 changes: 2 additions & 0 deletions stubs/pandapower-stubs/pypower/idx_vsc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ from typing import Final
VSC_MODE_AC_V: Final = 0
VSC_MODE_AC_Q: Final = 1
VSC_MODE_AC_SL: Final = 2
VSC_MODE_AC_P: Final = 3
VSC_MODE_AC_PHI: Final = 4

VSC_MODE_DC_V: Final = 0
VSC_MODE_DC_P: Final = 1
Expand Down
14 changes: 13 additions & 1 deletion stubs/pandapower-stubs/pypower/makeBdc.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
def makeBdc(bus, branch, return_csr: bool = True): ...
import numpy as np
from numpy.typing import NDArray

def makeBdc(
bus: NDArray[np.float64],
branch: NDArray[np.float64],
bus_dc: NDArray[np.float64] | None = None,
branch_dc: NDArray[np.float64] | None = None,
vsc: NDArray[np.float64] | None = None,
return_csr: bool = True,
): ...
def phase_shift_injection(b, shift, Cft): ...
def calc_b_from_branch(branch, nl): ...
def calc_b_from_branch_dc(branch): ...
def calc_b_from_vsc_dc(vsc): ...
1 change: 1 addition & 0 deletions stubs/pandapower-stubs/run.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def runpp(
tolerance_mva: Float = 1e-8,
trafo_model: Literal["t", "pi"] = "t",
trafo_loading: Literal["current", "power"] = "current",
enforce_p_lims: bool = False,
enforce_q_lims: bool = False,
check_connectivity: bool = True,
voltage_depend_loads: bool = True,
Expand Down
Loading
Loading