Skip to content

Commit 5d50398

Browse files
authored
project and pp updates (#24)
1 parent b0f9eca commit 5d50398

File tree

11 files changed

+3783
-505
lines changed

11 files changed

+3783
-505
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ jobs:
3434
- name: Install uv
3535
uses: astral-sh/setup-uv@v6
3636
- name: Install dependencies
37-
run: |
38-
uv venv
39-
uv pip install -r requirements.txt
37+
run: uv sync --frozen
4038
- name: Lint with ruff
4139
run: uv run python run.py ruff-check
4240
- name: Format with ruff
@@ -53,9 +51,7 @@ jobs:
5351
- name: Install uv
5452
uses: astral-sh/setup-uv@v6
5553
- name: Install dependencies
56-
run: |
57-
uv venv
58-
uv pip install -r requirements.txt
54+
run: uv sync --frozen
5955
- run: uv run python run.py pytest
6056
mypy:
6157
name: Run mypy on the tests and on the stubs
@@ -69,9 +65,7 @@ jobs:
6965
- name: Install uv
7066
uses: astral-sh/setup-uv@v6
7167
- name: Install dependencies
72-
run: |
73-
uv venv
74-
uv pip install -r requirements.txt
68+
run: uv sync --frozen
7569
- run: uv run python run.py mypy
7670
# stubtest:
7771
# name: Run stubtest on the the stubs
@@ -85,9 +79,7 @@ jobs:
8579
# - name: Install uv
8680
# uses: astral-sh/setup-uv@v6
8781
# - name: Install dependencies
88-
# run: |
89-
# uv venv
90-
# uv pip install -r requirements.txt
82+
# run: uv sync --frozen
9183
# - run: uv run python run.py stubtest
9284
pyright:
9385
name: Run pyright on the tests and on the stubs
@@ -101,7 +93,5 @@ jobs:
10193
- name: Install uv
10294
uses: astral-sh/setup-uv@v6
10395
- name: Install dependencies
104-
run: |
105-
uv venv
106-
uv pip install -r requirements.txt
96+
run: uv sync --frozen
10797
- run: uv run python run.py pyright

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: mixed-line-ending
1111
- id: check-case-conflict
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.9.1 # must match requirements.txt
13+
rev: v0.11.10 # must match requirements.txt
1414
hooks:
1515
- id: ruff
1616
- id: ruff-format

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ every change).
2323
Contributions of any kind are welcome. Please open an issue or a send pull request.
2424

2525
To set up a development environment:
26+
1. Install `uv`: https://docs.astral.sh/uv/getting-started/installation/
27+
2. Install the project dependencies: `uv sync --frozen`
28+
3. Run `uv run python run.py --help` for more.
29+
30+
Alternatively, if you want to use pip instead of `uv`:
2631
1. Create a virtual environment: `python -m .venv venv`
2732
2. Activate the virtual environment:
2833
- Unix: `. .venv/bin/activate`
2934
- Windows: `.venv\Scripts\activate`
30-
3. Install the dependencies: `python -m pip install -r requirements.txt`
31-
32-
Run `python run.py --help` for more.
35+
3. Update `pip`: `python -m pip install --upgrade pip`
36+
4. Install the dependencies: `python -m pip install -r requirements.txt`
37+
5. Run `python run.py --help` for more.
3338

3439
## License
3540

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@ name = "python-stubs"
33
version = "0.0.0"
44
requires-python = ">=3.9"
55

6+
[dependency-groups]
7+
tests = [
8+
# geopandas and shapely
9+
"types-geopandas>=1.0.1",
10+
"types-shapely>=2.0.0",
11+
"pandas-stubs>=2.2.2",
12+
"matplotlib>=3.8.0",
13+
"folium>=0.16.0",
14+
"rtree>=1.2.0",
15+
# netfields and psqlextra
16+
"django-types>=0.19.1",
17+
"djangorestframework-types>=0.8.0",
18+
"types-psycopg2>=2.9.21",
19+
"types-netaddr>=1.2.0",
20+
"types-python-dateutil>=2.9.0",
21+
# pandapower
22+
"networkx>=3.2.1",
23+
"geopandas>=1.0.0",
24+
]
25+
dev = [
26+
"ruff>=0.9.2",
27+
"pytest>=8.0",
28+
"rich-argparse>=1.6.0",
29+
"mypy>=1.14.1",
30+
"pyright>=1.1.392",
31+
{ include-group = "tests" },
32+
]
33+
634
[tool.ruff]
735
line-length = 130
836
fix = true

requirements.in

Lines changed: 0 additions & 29 deletions
This file was deleted.

requirements.txt

Lines changed: 1203 additions & 77 deletions
Large diffs are not rendered by default.

stubs/pandapower-stubs/auxiliary.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Iterable, Mapping, MutableMapping
2-
from typing import Any, Literal, NoReturn, SupportsFloat as Float, SupportsIndex as Int, TypeVar, overload
2+
from typing import Any, Final, Literal, NoReturn, SupportsFloat as Float, SupportsIndex as Int, TypeVar, overload
33
from typing_extensions import Self
44

55
import geopandas as gpd
@@ -140,7 +140,7 @@ def element_types_to_ets(element_types: None = None) -> pd.Series[str]: ...
140140
def element_types_to_ets(element_types: str) -> str: ...
141141
@overload
142142
def element_types_to_ets(element_types: list[str] | pd.Series[str] | pd.Index[str] | NDArray[np.str_]) -> list[str]: ...
143-
def get_free_id(df: pd.DataFrame) -> int: ...
143+
def get_free_id(df: pd.DataFrame) -> np.int64: ...
144144

145145
class ppException(Exception): ...
146146
class AlgorithmUnknown(ppException): ...
@@ -152,7 +152,7 @@ class MapboxTokenMissing(ppException): ...
152152

153153
def get_indices(
154154
selection: Iterable[Int], lookup: Mapping[Int, Int] | Mapping[str, Mapping[Int, Int]], fused_indices: bool = True
155-
) -> NDArray[np.int_]: ...
155+
) -> NDArray[np.int64]: ...
156156
def ensure_iterability(var: _T | Iterable[_T], len_: Int | None = None) -> Iterable[_T]: ...
157157
def read_from_net(
158158
net: pandapowerNet,
@@ -171,19 +171,19 @@ def write_to_net(
171171
) -> None: ...
172172

173173
# jit-ted functions
174-
def get_values(source, selection, lookup) -> NDArray[np.int_]: ...
174+
def get_values(source, selection, lookup) -> NDArray[np.int64]: ...
175175
def set_elements_oos(ti, tis, bis, lis) -> None: ...
176176
def set_isolated_buses_oos(bus_in_service, ppc_bus_isolated, bus_lookup) -> None: ...
177177
def X012_to_X0(X012: ArrayLike) -> NDArray[np.complex128]: ...
178178
def X012_to_X1(X012: ArrayLike) -> NDArray[np.complex128]: ...
179179
def X012_to_X2(X012: ArrayLike) -> NDArray[np.complex128]: ...
180180
def combine_X012(X0: ArrayLike, X1: ArrayLike, X2: ArrayLike) -> NDArray[np.complex128]: ...
181-
def phase_shift_unit_operator(angle_deg: Float) -> complex: ...
181+
def phase_shift_unit_operator(angle_deg: Float) -> np.complex128: ...
182182

183-
a: complex
184-
asq: complex
185-
Tabc: NDArray[np.complex128]
186-
T012: NDArray[np.complex128]
183+
a: Final[np.complex128]
184+
asq: Final[np.complex128]
185+
Tabc: Final[np.ndarray[tuple[int, int], np.dtype[np.complex128]]]
186+
T012: Final[np.ndarray[tuple[int, int], np.dtype[np.complex128]]]
187187

188188
def sequence_to_phase(X012: ArrayLike) -> NDArray[np.complex128]: ...
189189
def phase_to_sequence(Xabc: ArrayLike) -> NDArray[np.complex128]: ...

0 commit comments

Comments
 (0)