Skip to content

Commit cd290ac

Browse files
committed
Merge remote-tracking branch 'origin/main' into dependabot/github_actions/SonarSource/sonarqube-scan-action-5
2 parents 8ce4539 + fd030ea commit cd290ac

28 files changed

+265
-268
lines changed

docs/demos/connecting_new_consumer.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
" # Set the new feeder ids\n",
179179
" grid.set_feeder_ids()\n",
180180
"\n",
181-
" # Update the loadflow\n",
181+
" # Update the power flow\n",
182182
" core_interface = PowerGridModelInterface(grid=grid)\n",
183183
"\n",
184184
" core_interface.create_input_from_grid()\n",

docs/examples/model/grid_extensions_examples.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"\n",
1212
"## Adding columns to the Grid arrays\n",
1313
"\n",
14-
"Output variables are not present in the basic Grid as defined in gpm-ds, since these might or might not be useful to specific projects.\n",
14+
"Output variables are not present in the basic Grid as defined in pgm-ds, since these might or might not be useful to specific projects.\n",
1515
"To add these as you please you can extend the definitions of the arrays in your own project.\n"
1616
]
1717
},

docs/examples/pgm/basic_pgm_examples.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"source": [
77
"# PGM Calculation Engine Examples\n",
88
"\n",
9-
"These examples show how to interact with the [power-grid-model](https://github.com/PowerGridModel/power-grid-model) calculation engine to perform load flow calculations. For a detailed documentation on the calculation engine please refer to [power-grid-model docs](https://power-grid-model.readthedocs.io/en/stable/).\n"
9+
"These examples show how to interact with the [power-grid-model](https://github.com/PowerGridModel/power-grid-model) calculation engine to perform power flow calculations. For a detailed documentation on the calculation engine please refer to [power-grid-model docs](https://power-grid-model.readthedocs.io/en/stable/).\n"
1010
]
1111
},
1212
{
1313
"cell_type": "markdown",
1414
"metadata": {},
1515
"source": [
16-
"## Single Load Flow example\n",
16+
"## Single Power Flow example\n",
1717
"\n",
1818
"We will demonstrate how to use the PGMCoreInterface to perform Power Flow calculations on a `Grid` object.\n",
1919
"In the examples the `RadialGridGenerator` is used to create randomised input networks.\n"

docs/examples/utils/grid_from_txt_examples.ipynb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"If you follow a specific syntax, you can use the input from the\n",
2121
"graph editor to transfer your drawing to pgm-ds:\n",
2222
"\n",
23-
"- A _source node_ should be prefixed with `S`\n",
23+
"- A _substation node_ should be prefixed with `S`\n",
2424
" - e.g: `S1`, `S2`\n",
2525
"- A _line_ is defined as `<from_node> <to_node>`\n",
2626
" - From nodes can be both regular nodes and source nodes\n",
@@ -61,7 +61,7 @@
6161
},
6262
{
6363
"cell_type": "code",
64-
"execution_count": 9,
64+
"execution_count": 1,
6565
"metadata": {},
6666
"outputs": [],
6767
"source": [
@@ -84,29 +84,27 @@
8484
},
8585
{
8686
"cell_type": "code",
87-
"execution_count": 7,
87+
"execution_count": 2,
8888
"metadata": {},
8989
"outputs": [],
9090
"source": [
9191
"from power_grid_model_ds import Grid\n",
9292
"\n",
9393
"grid = Grid.from_txt(\n",
94-
" [\n",
95-
" \"S1 2\",\n",
96-
" \"S1 3 open\",\n",
97-
" \"2 7\",\n",
98-
" \"3 5\",\n",
99-
" \"3 6 transformer\",\n",
100-
" \"5 7\",\n",
101-
" \"7 8\",\n",
102-
" \"8 9\",\n",
103-
" ]\n",
94+
" \"S1 2\",\n",
95+
" \"S1 3 open\",\n",
96+
" \"2 7\",\n",
97+
" \"3 5\",\n",
98+
" \"3 6 transformer\",\n",
99+
" \"5 7\",\n",
100+
" \"7 8\",\n",
101+
" \"8 9\",\n",
104102
")"
105103
]
106104
},
107105
{
108106
"cell_type": "code",
109-
"execution_count": 10,
107+
"execution_count": 3,
110108
"metadata": {},
111109
"outputs": [
112110
{
@@ -132,7 +130,7 @@
132130
],
133131
"metadata": {
134132
"kernelspec": {
135-
"display_name": "Python 3 (ipykernel)",
133+
"display_name": "venv",
136134
"language": "python",
137135
"name": "python3"
138136
},
@@ -146,7 +144,7 @@
146144
"name": "python",
147145
"nbconvert_exporter": "python",
148146
"pygments_lexer": "ipython3",
149-
"version": "3.13.1"
147+
"version": "3.13.0"
150148
}
151149
},
152150
"nbformat": 4,

docs/model_interface.ipynb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,25 @@
8787
"cell_type": "markdown",
8888
"metadata": {},
8989
"source": [
90+
"```py\n",
9091
"target_line = grid.arrays.line.get(1)\n",
91-
"grid.make_active(target_branch_array=target_line)\n"
92+
"grid.make_active(target_branch_array=target_line)\n",
93+
"```\n"
9294
]
9395
},
9496
{
9597
"cell_type": "markdown",
9698
"metadata": {},
9799
"source": [
98-
"As seen above you can also make batch modification using the `grid.append` method.\n",
100+
"As seen above, you can also apply multiple modifications in one go using the `grid.append` method.\n",
99101
"\n",
100102
"## Array interface\n",
101103
"\n",
102-
"The array container is build around a extension of numpy arrays with the `FancyArray` class. This allows for easy and consistent definition of array types, recognition of array-type from it's class and features which improve readability such as dot-notation and autocompletion. It contains a `._data` attribute with the base numpy array and extra settings can be provided using `._defaults` and `._str_lengths`. Note these values should only be used in defining the array classes and remain private when using the arrays.\n",
104+
"The array container is build around an extension of numpy arrays with the `FancyArray` class. This allows for easy and consistent definition of array types, recognition of array-type from its class and features which improve readability such as dot-notation and autocompletion. It contains a `._data` attribute with the base numpy array and extra settings can be provided using `._defaults` and `._str_lengths`. Note these values should only be used in defining the array classes and remain private when using the arrays.\n",
103105
"\n",
104106
"### Array definition\n",
105107
"\n",
106-
"You can create your own array by subclassing FancyArray.\n",
108+
"You can create your own array by subclassing `FancyArray`.\n",
107109
"Array-columns can be defined by adding class attributes with the column name and the numpy dtype.\n",
108110
"\n",
109111
"Example:\n"
@@ -148,7 +150,7 @@
148150
"cell_type": "markdown",
149151
"metadata": {},
150152
"source": [
151-
"These are used when initializing an array with the .empty method\n"
153+
"These are used when initializing an array with the `.empty` method\n"
152154
]
153155
},
154156
{
@@ -190,7 +192,7 @@
190192
"\n",
191193
"### Array loops\n",
192194
"\n",
193-
"Looping over large arrays can be a performance hit, this is caused by casting each row to the original `FancyArray` subclass. When you want to implement a faster loop over the array you can choose to access the `array.data` directly and create the loop using\n"
195+
"Looping over large arrays can incur a performance hit caused by conversion of each element to the original `FancyArray` subclass. When you want to implement a faster loop over the array you can choose to access the `array.data` directly and create the loop using\n"
194196
]
195197
},
196198
{

docs/quick_start.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"source": [
77
"# Quick Start\n",
88
"\n",
9-
"In this quick start we create an extension of the Grid object, generate a random instance of it and perform loadflow calculations and modifactions.\n"
9+
"In this quick start we create an extension of the Grid object, generate a random instance of it and perform power flow calculations and modifications.\n"
1010
]
1111
},
1212
{
@@ -15,7 +15,7 @@
1515
"source": [
1616
"## Setting up a grid extension\n",
1717
"\n",
18-
"This shows how to add extra values to a `Grid` object. If these are present in the PGM output they will updated after a loadflow calculation.\n"
18+
"This shows how to add extra values to a `Grid` object. If these are present in the PGM output they will be updated after a power flow calculation.\n"
1919
]
2020
},
2121
{
@@ -105,7 +105,7 @@
105105
"cell_type": "markdown",
106106
"metadata": {},
107107
"source": [
108-
"## Performing Loadflow calculations\n",
108+
"## Performing power flow calculations\n",
109109
"\n",
110110
"Using the `PowerGridModelInterface` the `Grid` data can be provided to the calculation engine. Using `update_grid` values can be transferred to the `Grid` object.\n"
111111
]
@@ -198,7 +198,7 @@
198198
"source": [
199199
"## Analyzing Grid structure\n",
200200
"\n",
201-
"The `Grid` also contains a graph representation which can be used for anayling structure. Such as finding the shortest path between two nodes.\n"
201+
"The `Grid` also contains a graph representation which can be used for analyzing structure. Such as finding the shortest path between two nodes.\n"
202202
]
203203
},
204204
{

src/power_grid_model_ds/_core/load_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: MPL-2.0
44

5-
"""Load flow functions and classes"""
5+
"""Power flow functions and classes"""
66

77
from typing import Dict, Optional
88

src/power_grid_model_ds/_core/model/containers/grid_protocol.py

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

src/power_grid_model_ds/_core/model/graphs/container.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66

77
import dataclasses
88
from dataclasses import dataclass
9-
from typing import Generator
9+
from typing import TYPE_CHECKING, Generator
1010

1111
import numpy as np
1212

1313
from power_grid_model_ds._core.model.arrays import Branch3Array, BranchArray, NodeArray
1414
from power_grid_model_ds._core.model.arrays.base.array import FancyArray
1515
from power_grid_model_ds._core.model.arrays.base.errors import RecordDoesNotExist
16-
from power_grid_model_ds._core.model.containers.grid_protocol import MinimalGridArrays
1716
from power_grid_model_ds._core.model.graphs.models import RustworkxGraphModel
1817
from power_grid_model_ds._core.model.graphs.models.base import BaseGraphModel
1918

19+
if TYPE_CHECKING: # pragma: no cover
20+
from power_grid_model_ds._core.model.grids.base import Grid
21+
2022

2123
@dataclass
2224
class GraphContainer:
@@ -119,7 +121,7 @@ def make_inactive(self, branch: BranchArray) -> None:
119121
setattr(self, field.name, graph)
120122

121123
@classmethod
122-
def from_arrays(cls, arrays: MinimalGridArrays) -> "GraphContainer":
124+
def from_arrays(cls, arrays: "Grid") -> "GraphContainer":
123125
"""Build from arrays"""
124126
cls._validate_branches(arrays=arrays)
125127

@@ -132,7 +134,7 @@ def from_arrays(cls, arrays: MinimalGridArrays) -> "GraphContainer":
132134
return new_container
133135

134136
@staticmethod
135-
def _validate_branches(arrays: MinimalGridArrays):
137+
def _validate_branches(arrays: "Grid") -> None:
136138
for array in arrays.branch_arrays:
137139
if any(~np.isin(array.from_node, arrays.node.id)):
138140
raise RecordDoesNotExist(f"Found invalid .from_node values in {array.__class__.__name__}")

src/power_grid_model_ds/_core/model/graphs/models/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44

55
from abc import ABC, abstractmethod
66
from contextlib import contextmanager
7-
from typing import Generator
7+
from typing import TYPE_CHECKING, Generator
88

99
import numpy as np
1010
from numpy._typing import NDArray
1111

1212
from power_grid_model_ds._core.model.arrays.pgm_arrays import Branch3Array, BranchArray, NodeArray
13-
from power_grid_model_ds._core.model.containers.grid_protocol import MinimalGridArrays
1413
from power_grid_model_ds._core.model.graphs.errors import (
1514
GraphError,
1615
MissingBranchError,
1716
MissingNodeError,
1817
NoPathBetweenNodes,
1918
)
2019

20+
if TYPE_CHECKING: # pragma: no cover
21+
from power_grid_model_ds._core.model.grids.base import Grid
22+
2123

2224
# pylint: disable=too-many-public-methods
2325
class BaseGraphModel(ABC):
@@ -327,7 +329,7 @@ def find_fundamental_cycles(self) -> list[list[int]]:
327329
return [self._internals_to_externals(nodes) for nodes in internal_cycles]
328330

329331
@classmethod
330-
def from_arrays(cls, arrays: MinimalGridArrays, active_only=False) -> "BaseGraphModel":
332+
def from_arrays(cls, arrays: "Grid", active_only=False) -> "BaseGraphModel":
331333
"""Build from arrays"""
332334
new_graph = cls(active_only=active_only)
333335

0 commit comments

Comments
 (0)