power-grid-model 1.10.74__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.

Files changed (67) hide show
  1. power_grid_model/__init__.py +54 -29
  2. power_grid_model/_core/__init__.py +3 -3
  3. power_grid_model/_core/buffer_handling.py +507 -478
  4. power_grid_model/_core/data_handling.py +195 -141
  5. power_grid_model/_core/data_types.py +142 -0
  6. power_grid_model/_core/dataset_definitions.py +109 -109
  7. power_grid_model/_core/enum.py +226 -0
  8. power_grid_model/_core/error_handling.py +215 -202
  9. power_grid_model/_core/errors.py +134 -0
  10. power_grid_model/_core/index_integer.py +17 -17
  11. power_grid_model/_core/options.py +71 -69
  12. power_grid_model/_core/power_grid_core.py +577 -597
  13. power_grid_model/_core/power_grid_dataset.py +545 -528
  14. power_grid_model/_core/power_grid_meta.py +262 -244
  15. power_grid_model/_core/power_grid_model.py +1025 -692
  16. power_grid_model/_core/power_grid_model_c/__init__.py +3 -0
  17. power_grid_model/_core/power_grid_model_c/bin/power_grid_model_c.dll +0 -0
  18. power_grid_model/_core/power_grid_model_c/get_pgm_dll_path.py +63 -0
  19. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/basics.h +251 -0
  20. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/buffer.h +108 -0
  21. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset.h +332 -0
  22. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1060 -0
  23. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +111 -0
  24. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/meta_data.h +189 -0
  25. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/model.h +130 -0
  26. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/options.h +142 -0
  27. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/serialization.h +118 -0
  28. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c.h +36 -0
  29. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/basics.hpp +65 -0
  30. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/buffer.hpp +61 -0
  31. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/dataset.hpp +224 -0
  32. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/handle.hpp +108 -0
  33. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/meta_data.hpp +84 -0
  34. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/model.hpp +63 -0
  35. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/options.hpp +52 -0
  36. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/serialization.hpp +124 -0
  37. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/utils.hpp +81 -0
  38. power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp.hpp +19 -0
  39. power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfig.cmake +37 -0
  40. power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfigVersion.cmake +65 -0
  41. power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets-release.cmake +19 -0
  42. power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets.cmake +144 -0
  43. power_grid_model/_core/power_grid_model_c/lib/power_grid_model_c.lib +0 -0
  44. power_grid_model/_core/power_grid_model_c/share/LICENSE +292 -0
  45. power_grid_model/_core/power_grid_model_c/share/README.md +15 -0
  46. power_grid_model/_core/serialization.py +319 -317
  47. power_grid_model/_core/typing.py +20 -0
  48. power_grid_model/{_utils.py → _core/utils.py} +798 -783
  49. power_grid_model/data_types.py +321 -319
  50. power_grid_model/enum.py +27 -214
  51. power_grid_model/errors.py +37 -123
  52. power_grid_model/typing.py +43 -48
  53. power_grid_model/utils.py +529 -400
  54. power_grid_model/validation/__init__.py +25 -14
  55. power_grid_model/validation/_rules.py +1167 -904
  56. power_grid_model/validation/_validation.py +1172 -980
  57. power_grid_model/validation/assertions.py +93 -92
  58. power_grid_model/validation/errors.py +602 -520
  59. power_grid_model/validation/utils.py +313 -318
  60. {power_grid_model-1.10.74.dist-info → power_grid_model-1.12.119.dist-info}/METADATA +162 -171
  61. power_grid_model-1.12.119.dist-info/RECORD +65 -0
  62. {power_grid_model-1.10.74.dist-info → power_grid_model-1.12.119.dist-info}/WHEEL +1 -1
  63. power_grid_model-1.12.119.dist-info/entry_points.txt +3 -0
  64. power_grid_model/_core/_power_grid_core.dll +0 -0
  65. power_grid_model-1.10.74.dist-info/RECORD +0 -32
  66. power_grid_model-1.10.74.dist-info/top_level.txt +0 -1
  67. {power_grid_model-1.10.74.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
- from power_grid_model.data_types import BatchDataset, SingleDataset
10
- from power_grid_model.enum import CalculationType
11
- from power_grid_model.validation._validation import validate_batch_data, validate_input_data
12
- from power_grid_model.validation.errors import ValidationError
13
- from power_grid_model.validation.utils import errors_to_string
14
-
15
-
16
- class ValidationException(ValueError):
17
- """
18
- An exception storing the name of the validated data, a list/dict of errors and a convenient conversion to string
19
- to display a summary of all the errors when printing the exception.
20
- """
21
-
22
- def __init__(self, errors: list[ValidationError] | dict[int, list[ValidationError]], name: str = "data"):
23
- super().__init__(f"Invalid {name}")
24
- self.errors = errors
25
- self.name = name
26
-
27
- def __str__(self):
28
- return errors_to_string(errors=self.errors, name=self.name)
29
-
30
-
31
- def assert_valid_input_data(
32
- input_data: SingleDataset, calculation_type: CalculationType | None = None, symmetric: bool = True
33
- ):
34
- """
35
- Validates the entire input dataset:
36
-
37
- 1. Is the data structure correct? (checking data types and numpy array shapes)
38
- 2. Are all required values provided? (checking NaNs)
39
- 3. Are all ID's unique? (checking object identifiers across all components)
40
- 4. Are the supplied values valid? (checking limits and other logic as described in "Graph Data Model")
41
-
42
- Args:
43
- input_data: A power-grid-model input dataset
44
- calculation_type: Supply a calculation method, to allow missing values for unused fields
45
- symmetric: A boolean to state whether input data will be used for a symmetric or asymmetric calculation
46
-
47
- Raises:
48
- KeyError | TypeError | ValueError: if the data structure is invalid.
49
- ValidationException: if the contents are invalid.
50
- """
51
- validation_errors = validate_input_data(
52
- input_data=input_data, calculation_type=calculation_type, symmetric=symmetric
53
- )
54
- if validation_errors:
55
- raise ValidationException(validation_errors, "input_data")
56
-
57
-
58
- def assert_valid_batch_data(
59
- input_data: SingleDataset,
60
- update_data: BatchDataset,
61
- calculation_type: CalculationType | None = None,
62
- symmetric: bool = True,
63
- ):
64
- """
65
- The input dataset is validated:
66
-
67
- 1. Is the data structure correct? (checking data types and numpy array shapes)
68
- 2. Are all input data ID's unique? (checking object identifiers across all components)
69
-
70
- For each batch the update data is validated:
71
- 3. Is the update data structure correct? (checking data types and numpy array shapes)
72
- 4. Are all update ID's valid? (checking object identifiers across update and input data)
73
-
74
- Then (for each batch independently) the input dataset is updated with the batch's update data and validated:
75
- 5. Are all required values provided? (checking NaNs)
76
- 6. Are the supplied values valid? (checking limits and other logic as described in "Graph Data Model")
77
-
78
- Args:
79
- input_data: a power-grid-model input dataset
80
- update_data: a power-grid-model update dataset (one or more batches)
81
- calculation_type: Supply a calculation method, to allow missing values for unused fields
82
- symmetric: A boolean to state whether input data will be used for a symmetric or asymmetric calculation
83
-
84
- Raises:
85
- KeyError | TypeError | ValueError: if the data structure is invalid.
86
- ValidationException: if the contents are invalid.
87
- """
88
- validation_errors = validate_batch_data(
89
- input_data=input_data, update_data=update_data, calculation_type=calculation_type, symmetric=symmetric
90
- )
91
- if validation_errors:
92
- raise ValidationException(validation_errors, "update_data")
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")