power-grid-model 1.10.17__py3-none-win_amd64.whl → 1.12.119__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of power-grid-model might be problematic. Click here for more details.
- power_grid_model/__init__.py +54 -29
- power_grid_model/_core/__init__.py +3 -3
- power_grid_model/_core/buffer_handling.py +507 -478
- power_grid_model/_core/data_handling.py +195 -141
- power_grid_model/_core/data_types.py +142 -0
- power_grid_model/_core/dataset_definitions.py +109 -109
- power_grid_model/_core/enum.py +226 -0
- power_grid_model/_core/error_handling.py +215 -198
- power_grid_model/_core/errors.py +134 -0
- power_grid_model/_core/index_integer.py +17 -17
- power_grid_model/_core/options.py +71 -69
- power_grid_model/_core/power_grid_core.py +577 -562
- power_grid_model/_core/power_grid_dataset.py +545 -490
- power_grid_model/_core/power_grid_meta.py +262 -244
- power_grid_model/_core/power_grid_model.py +1025 -687
- power_grid_model/_core/power_grid_model_c/__init__.py +3 -0
- power_grid_model/_core/power_grid_model_c/bin/power_grid_model_c.dll +0 -0
- power_grid_model/_core/power_grid_model_c/get_pgm_dll_path.py +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/basics.h +251 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/buffer.h +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset.h +332 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1060 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +111 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/meta_data.h +189 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/model.h +130 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/options.h +142 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/serialization.h +118 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c.h +36 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/basics.hpp +65 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/buffer.hpp +61 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/dataset.hpp +224 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/handle.hpp +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/meta_data.hpp +84 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/model.hpp +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/options.hpp +52 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/serialization.hpp +124 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/utils.hpp +81 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp.hpp +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfig.cmake +37 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfigVersion.cmake +65 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets-release.cmake +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets.cmake +144 -0
- power_grid_model/_core/power_grid_model_c/lib/power_grid_model_c.lib +0 -0
- power_grid_model/_core/power_grid_model_c/share/LICENSE +292 -0
- power_grid_model/_core/power_grid_model_c/share/README.md +15 -0
- power_grid_model/_core/serialization.py +319 -317
- power_grid_model/_core/typing.py +20 -0
- power_grid_model/{_utils.py → _core/utils.py} +798 -783
- power_grid_model/data_types.py +321 -319
- power_grid_model/enum.py +27 -214
- power_grid_model/errors.py +37 -119
- power_grid_model/typing.py +43 -48
- power_grid_model/utils.py +529 -400
- power_grid_model/validation/__init__.py +25 -10
- power_grid_model/validation/{rules.py → _rules.py} +1167 -962
- power_grid_model/validation/{validation.py → _validation.py} +1172 -1015
- power_grid_model/validation/assertions.py +93 -92
- power_grid_model/validation/errors.py +602 -524
- power_grid_model/validation/utils.py +313 -318
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info}/METADATA +162 -165
- power_grid_model-1.12.119.dist-info/RECORD +65 -0
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info}/WHEEL +1 -1
- power_grid_model-1.12.119.dist-info/entry_points.txt +3 -0
- power_grid_model/_core/_power_grid_core.dll +0 -0
- power_grid_model-1.10.17.dist-info/RECORD +0 -32
- power_grid_model-1.10.17.dist-info/top_level.txt +0 -1
- {power_grid_model-1.10.17.dist-info → power_grid_model-1.12.119.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,92 +1,93 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
"""
|
|
6
|
-
Helper functions to assert valid data. They basically call validate_input_data or validate_batch_data and raise a
|
|
7
|
-
ValidationException if the validation results in one or more errors.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from power_grid_model.enum import CalculationType
|
|
11
|
-
from power_grid_model.
|
|
12
|
-
from power_grid_model.validation.
|
|
13
|
-
from power_grid_model.validation.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
self.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Helper functions to assert valid data. They basically call validate_input_data or validate_batch_data and raise a
|
|
7
|
+
ValidationException if the validation results in one or more errors.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from power_grid_model._core.enum import CalculationType
|
|
11
|
+
from power_grid_model.data_types import BatchDataset, SingleDataset
|
|
12
|
+
from power_grid_model.validation._validation import validate_batch_data, validate_input_data
|
|
13
|
+
from power_grid_model.validation.errors import ValidationError
|
|
14
|
+
from power_grid_model.validation.utils import errors_to_string
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ValidationException(ValueError):
|
|
18
|
+
"""
|
|
19
|
+
An exception storing the name of the validated data, a list/dict of errors and a convenient conversion to string
|
|
20
|
+
to display a summary of all the errors when printing the exception.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, errors: list[ValidationError] | dict[int, list[ValidationError]], name: str = "data"):
|
|
24
|
+
super().__init__(f"Invalid {name}")
|
|
25
|
+
self.errors = errors
|
|
26
|
+
self.name = name
|
|
27
|
+
|
|
28
|
+
def __str__(self):
|
|
29
|
+
return errors_to_string(errors=self.errors, name=self.name)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def assert_valid_input_data(
|
|
33
|
+
input_data: SingleDataset, calculation_type: CalculationType | None = None, symmetric: bool = True
|
|
34
|
+
):
|
|
35
|
+
"""
|
|
36
|
+
Validates the entire input dataset:
|
|
37
|
+
|
|
38
|
+
1. Is the data structure correct? (checking data types and numpy array shapes)
|
|
39
|
+
2. Are all required values provided? (checking NaNs)
|
|
40
|
+
3. Are all ID's unique? (checking object identifiers across all components)
|
|
41
|
+
4. Are the supplied values valid? (checking limits and other logic as described in "Graph Data Model")
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
input_data: A power-grid-model input dataset
|
|
45
|
+
calculation_type: Supply a calculation method, to allow missing values for unused fields
|
|
46
|
+
symmetric: A boolean to state whether input data will be used for a symmetric or asymmetric calculation
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
KeyError | TypeError | ValueError: if the data structure is invalid.
|
|
50
|
+
ValidationException: if the contents are invalid.
|
|
51
|
+
"""
|
|
52
|
+
validation_errors = validate_input_data(
|
|
53
|
+
input_data=input_data, calculation_type=calculation_type, symmetric=symmetric
|
|
54
|
+
)
|
|
55
|
+
if validation_errors:
|
|
56
|
+
raise ValidationException(validation_errors, "input_data")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def assert_valid_batch_data(
|
|
60
|
+
input_data: SingleDataset,
|
|
61
|
+
update_data: BatchDataset,
|
|
62
|
+
calculation_type: CalculationType | None = None,
|
|
63
|
+
symmetric: bool = True,
|
|
64
|
+
):
|
|
65
|
+
"""
|
|
66
|
+
The input dataset is validated:
|
|
67
|
+
|
|
68
|
+
1. Is the data structure correct? (checking data types and numpy array shapes)
|
|
69
|
+
2. Are all input data ID's unique? (checking object identifiers across all components)
|
|
70
|
+
|
|
71
|
+
For each batch the update data is validated:
|
|
72
|
+
3. Is the update data structure correct? (checking data types and numpy array shapes)
|
|
73
|
+
4. Are all update ID's valid? (checking object identifiers across update and input data)
|
|
74
|
+
|
|
75
|
+
Then (for each batch independently) the input dataset is updated with the batch's update data and validated:
|
|
76
|
+
5. Are all required values provided? (checking NaNs)
|
|
77
|
+
6. Are the supplied values valid? (checking limits and other logic as described in "Graph Data Model")
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
input_data: a power-grid-model input dataset
|
|
81
|
+
update_data: a power-grid-model update dataset (one or more batches)
|
|
82
|
+
calculation_type: Supply a calculation method, to allow missing values for unused fields
|
|
83
|
+
symmetric: A boolean to state whether input data will be used for a symmetric or asymmetric calculation
|
|
84
|
+
|
|
85
|
+
Raises:
|
|
86
|
+
KeyError | TypeError | ValueError: if the data structure is invalid.
|
|
87
|
+
ValidationException: if the contents are invalid.
|
|
88
|
+
"""
|
|
89
|
+
validation_errors = validate_batch_data(
|
|
90
|
+
input_data=input_data, update_data=update_data, calculation_type=calculation_type, symmetric=symmetric
|
|
91
|
+
)
|
|
92
|
+
if validation_errors:
|
|
93
|
+
raise ValidationException(validation_errors, "update_data")
|