power-grid-model 1.11.23__py3-none-win_amd64.whl → 1.12.70__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.
Files changed (67) hide show
  1. power_grid_model/__init__.py +54 -52
  2. power_grid_model/_core/__init__.py +3 -3
  3. power_grid_model/_core/buffer_handling.py +493 -478
  4. power_grid_model/_core/data_handling.py +195 -141
  5. power_grid_model/_core/data_types.py +143 -132
  6. power_grid_model/_core/dataset_definitions.py +109 -108
  7. power_grid_model/_core/enum.py +226 -226
  8. power_grid_model/_core/error_handling.py +206 -205
  9. power_grid_model/_core/errors.py +130 -126
  10. power_grid_model/_core/index_integer.py +17 -17
  11. power_grid_model/_core/options.py +71 -70
  12. power_grid_model/_core/power_grid_core.py +563 -581
  13. power_grid_model/_core/power_grid_dataset.py +535 -534
  14. power_grid_model/_core/power_grid_meta.py +257 -243
  15. power_grid_model/_core/power_grid_model.py +969 -687
  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 +255 -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 +316 -0
  22. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1052 -0
  23. power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +99 -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 +125 -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 +220 -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 +317 -317
  47. power_grid_model/_core/typing.py +20 -20
  48. power_grid_model/_core/utils.py +798 -789
  49. power_grid_model/data_types.py +321 -307
  50. power_grid_model/enum.py +27 -27
  51. power_grid_model/errors.py +37 -37
  52. power_grid_model/typing.py +43 -43
  53. power_grid_model/utils.py +473 -465
  54. power_grid_model/validation/__init__.py +25 -25
  55. power_grid_model/validation/_rules.py +1171 -1175
  56. power_grid_model/validation/_validation.py +1172 -1158
  57. power_grid_model/validation/assertions.py +93 -93
  58. power_grid_model/validation/errors.py +602 -588
  59. power_grid_model/validation/utils.py +313 -321
  60. {power_grid_model-1.11.23.dist-info → power_grid_model-1.12.70.dist-info}/METADATA +178 -180
  61. power_grid_model-1.12.70.dist-info/RECORD +65 -0
  62. {power_grid_model-1.11.23.dist-info → power_grid_model-1.12.70.dist-info}/WHEEL +1 -1
  63. power_grid_model-1.12.70.dist-info/entry_points.txt +3 -0
  64. power_grid_model/_core/_power_grid_core.dll +0 -0
  65. power_grid_model-1.11.23.dist-info/RECORD +0 -36
  66. power_grid_model-1.11.23.dist-info/top_level.txt +0 -1
  67. {power_grid_model-1.11.23.dist-info → power_grid_model-1.12.70.dist-info}/licenses/LICENSE +0 -0
@@ -1,93 +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.data_types import BatchDataset, SingleDataset
11
- from power_grid_model.enum import CalculationType
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")
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")