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,244 +1,262 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
"""
|
|
6
|
-
Load meta data from C core and define numpy structured array
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
from dataclasses import dataclass
|
|
10
|
-
from enum import IntEnum
|
|
11
|
-
from typing import Any
|
|
12
|
-
|
|
13
|
-
import numpy as np
|
|
14
|
-
|
|
15
|
-
from power_grid_model._core.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
from power_grid_model.
|
|
25
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
"""
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
def
|
|
229
|
-
data_type: DatasetTypeLike, component_type: ComponentTypeLike, attribute: AttributeType
|
|
230
|
-
) -> np.
|
|
231
|
-
"""
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
1
|
+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Load meta data from C core and define numpy structured array
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from enum import IntEnum
|
|
11
|
+
from typing import Any, overload
|
|
12
|
+
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
15
|
+
from power_grid_model._core.data_types import AttributeType, DenseBatchArray, SingleArray
|
|
16
|
+
from power_grid_model._core.dataset_definitions import (
|
|
17
|
+
ComponentTypeLike,
|
|
18
|
+
ComponentTypeVar,
|
|
19
|
+
DatasetType,
|
|
20
|
+
DatasetTypeLike,
|
|
21
|
+
_str_to_component_type,
|
|
22
|
+
_str_to_datatype,
|
|
23
|
+
)
|
|
24
|
+
from power_grid_model._core.power_grid_core import (
|
|
25
|
+
AttributePtr,
|
|
26
|
+
ComponentPtr,
|
|
27
|
+
DatasetPtr,
|
|
28
|
+
get_power_grid_core as get_pgc,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# constant enum for ctype
|
|
33
|
+
class PGMCType(IntEnum):
|
|
34
|
+
"""enumeration for ctype"""
|
|
35
|
+
|
|
36
|
+
int32 = 0
|
|
37
|
+
int8 = 1
|
|
38
|
+
double = 2
|
|
39
|
+
double3 = 3
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
_CTYPE_NUMPY_MAP = {PGMCType.double: "f8", PGMCType.int32: "i4", PGMCType.int8: "i1", PGMCType.double3: "(3,)f8"}
|
|
43
|
+
_ENDIANNESS = "<" if get_pgc().is_little_endian() == 1 else ">"
|
|
44
|
+
_NAN_VALUE_MAP = {
|
|
45
|
+
f"{_ENDIANNESS}f8": np.nan,
|
|
46
|
+
f"{_ENDIANNESS}(3,)f8": np.nan,
|
|
47
|
+
f"{_ENDIANNESS}i4": np.iinfo(f"{_ENDIANNESS}i4").min,
|
|
48
|
+
f"{_ENDIANNESS}i1": np.iinfo(f"{_ENDIANNESS}i1").min,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@dataclass
|
|
53
|
+
class ComponentMetaData:
|
|
54
|
+
"""
|
|
55
|
+
Data class for component metadata
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
dtype: np.dtype
|
|
59
|
+
dtype_dict: dict[str, Any]
|
|
60
|
+
nans: dict[str, float | int]
|
|
61
|
+
nan_scalar: np.ndarray
|
|
62
|
+
|
|
63
|
+
def __getitem__(self, item):
|
|
64
|
+
"""
|
|
65
|
+
Get item of dataclass
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
item: item name
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
|
|
72
|
+
"""
|
|
73
|
+
return getattr(self, item)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
DatasetMetaData = dict[ComponentTypeVar, ComponentMetaData]
|
|
77
|
+
PowerGridMetaData = dict[DatasetType, DatasetMetaData]
|
|
78
|
+
"""
|
|
79
|
+
The data types for all dataset types and components used by the Power Grid Model.
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _generate_meta_data() -> PowerGridMetaData:
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
Returns: meta data for all dataset
|
|
87
|
+
|
|
88
|
+
"""
|
|
89
|
+
py_meta_data = {}
|
|
90
|
+
n_datasets = get_pgc().meta_n_datasets()
|
|
91
|
+
for i in range(n_datasets):
|
|
92
|
+
dataset = get_pgc().meta_get_dataset_by_idx(i)
|
|
93
|
+
py_meta_data[_str_to_datatype(get_pgc().meta_dataset_name(dataset))] = _generate_meta_dataset(dataset)
|
|
94
|
+
return py_meta_data
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _generate_meta_dataset(dataset: DatasetPtr) -> DatasetMetaData:
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
dataset: dataset
|
|
102
|
+
|
|
103
|
+
Returns: meta data for one dataset
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
py_meta_dataset = {}
|
|
107
|
+
n_components = get_pgc().meta_n_components(dataset)
|
|
108
|
+
for i in range(n_components):
|
|
109
|
+
component = get_pgc().meta_get_component_by_idx(dataset, i)
|
|
110
|
+
py_meta_dataset[_str_to_component_type(get_pgc().meta_component_name(component))] = _generate_meta_component(
|
|
111
|
+
component
|
|
112
|
+
)
|
|
113
|
+
return py_meta_dataset
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _generate_meta_component(component: ComponentPtr) -> ComponentMetaData:
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
component: component
|
|
121
|
+
|
|
122
|
+
Returns: meta data for one component
|
|
123
|
+
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
dtype_dict = _generate_meta_attributes(component)
|
|
127
|
+
dtype = np.dtype({k: v for k, v in dtype_dict.items() if k != "nans"}) # type: ignore
|
|
128
|
+
nans = dict(zip(dtype_dict["names"], dtype_dict["nans"]))
|
|
129
|
+
if dtype.alignment != get_pgc().meta_component_alignment(component):
|
|
130
|
+
raise TypeError(f'Aligment mismatch for component type: "{get_pgc().meta_component_name(component)}" !')
|
|
131
|
+
# get single nan scalar
|
|
132
|
+
nan_scalar = np.empty(1, dtype=dtype)
|
|
133
|
+
for key, value in nans.items():
|
|
134
|
+
nan_scalar[key] = value
|
|
135
|
+
return ComponentMetaData(dtype=dtype, dtype_dict=dtype_dict, nans=nans, nan_scalar=nan_scalar)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _generate_meta_attributes(component: ComponentPtr) -> dict:
|
|
139
|
+
"""
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
component: component
|
|
143
|
+
|
|
144
|
+
Returns: meta data for all attributes
|
|
145
|
+
|
|
146
|
+
"""
|
|
147
|
+
names = []
|
|
148
|
+
formats = []
|
|
149
|
+
offsets = []
|
|
150
|
+
nans = []
|
|
151
|
+
n_attrs = get_pgc().meta_n_attributes(component)
|
|
152
|
+
for i in range(n_attrs):
|
|
153
|
+
attribute: AttributePtr = get_pgc().meta_get_attribute_by_idx(component, i)
|
|
154
|
+
attr_name: str = get_pgc().meta_attribute_name(attribute)
|
|
155
|
+
attr_ctype: int = get_pgc().meta_attribute_ctype(attribute)
|
|
156
|
+
attr_offset: int = get_pgc().meta_attribute_offset(attribute)
|
|
157
|
+
attr_np_type = f"{_ENDIANNESS}{_CTYPE_NUMPY_MAP[PGMCType(attr_ctype)]}"
|
|
158
|
+
attr_nan = _NAN_VALUE_MAP[attr_np_type]
|
|
159
|
+
names.append(attr_name)
|
|
160
|
+
formats.append(attr_np_type)
|
|
161
|
+
offsets.append(attr_offset)
|
|
162
|
+
nans.append(attr_nan)
|
|
163
|
+
return {
|
|
164
|
+
"names": names,
|
|
165
|
+
"formats": formats,
|
|
166
|
+
"offsets": offsets,
|
|
167
|
+
"itemsize": get_pgc().meta_component_size(component),
|
|
168
|
+
"aligned": True,
|
|
169
|
+
"nans": nans,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# store meta data
|
|
174
|
+
power_grid_meta_data = _generate_meta_data()
|
|
175
|
+
"""
|
|
176
|
+
The data types for all dataset types and components used by the Power Grid Model.
|
|
177
|
+
"""
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@overload
|
|
181
|
+
def initialize_array(
|
|
182
|
+
data_type: DatasetTypeLike,
|
|
183
|
+
component_type: ComponentTypeLike,
|
|
184
|
+
shape: int | tuple[int],
|
|
185
|
+
empty: bool = False,
|
|
186
|
+
) -> SingleArray: ...
|
|
187
|
+
@overload
|
|
188
|
+
def initialize_array(
|
|
189
|
+
data_type: DatasetTypeLike,
|
|
190
|
+
component_type: ComponentTypeLike,
|
|
191
|
+
shape: tuple[int, int],
|
|
192
|
+
empty: bool = False,
|
|
193
|
+
) -> DenseBatchArray: ...
|
|
194
|
+
def initialize_array(
|
|
195
|
+
data_type: DatasetTypeLike,
|
|
196
|
+
component_type: ComponentTypeLike,
|
|
197
|
+
shape: int | tuple[int] | tuple[int, int],
|
|
198
|
+
empty: bool = False,
|
|
199
|
+
) -> SingleArray | DenseBatchArray:
|
|
200
|
+
"""
|
|
201
|
+
Initializes an array for use in Power Grid Model calculations
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
data_type: input, update, sym_output, or asym_output
|
|
205
|
+
component_type: one component type, e.g. node
|
|
206
|
+
shape: shape of initialization
|
|
207
|
+
integer, it is a 1-dimensional array
|
|
208
|
+
tuple, it is an N-dimensional (tuple.shape) array
|
|
209
|
+
empty: if True, leave the memory block un-initialized
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
np structured array with all entries as null value
|
|
213
|
+
"""
|
|
214
|
+
data_type = _str_to_datatype(data_type)
|
|
215
|
+
component_type = _str_to_component_type(component_type)
|
|
216
|
+
if not isinstance(shape, tuple):
|
|
217
|
+
shape = (shape,)
|
|
218
|
+
if empty:
|
|
219
|
+
return np.empty(shape=shape, dtype=power_grid_meta_data[data_type][component_type].dtype, order="C")
|
|
220
|
+
return np.full(
|
|
221
|
+
shape=shape,
|
|
222
|
+
fill_value=power_grid_meta_data[data_type][component_type].nan_scalar,
|
|
223
|
+
dtype=power_grid_meta_data[data_type][component_type].dtype,
|
|
224
|
+
order="C",
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def attribute_dtype(
|
|
229
|
+
data_type: DatasetTypeLike, component_type: ComponentTypeLike, attribute: AttributeType
|
|
230
|
+
) -> np.dtype:
|
|
231
|
+
"""Gives out dtype of the attribute to be used in a columnar data format
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
data_type (DatasetTypeLike): The type of dataset (input, update, sym_output, or asym_output)
|
|
235
|
+
component_type (ComponentTypeLike): The type of component (e.g., node)
|
|
236
|
+
attribute (AttributeType): The attribute whose dtype is required
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
np.dtype: The dtype of the specified attribute
|
|
240
|
+
"""
|
|
241
|
+
data_type = _str_to_datatype(data_type)
|
|
242
|
+
component_type = _str_to_component_type(component_type)
|
|
243
|
+
return power_grid_meta_data[data_type][component_type].dtype[attribute]
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def attribute_empty_value(
|
|
247
|
+
data_type: DatasetTypeLike, component_type: ComponentTypeLike, attribute: AttributeType
|
|
248
|
+
) -> np.ndarray:
|
|
249
|
+
"""
|
|
250
|
+
Returns the empty value for a specific attribute in the Power Grid Model.
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
data_type (DatasetTypeLike): The type of dataset (input, update, sym_output, or asym_output)
|
|
254
|
+
component_type (ComponentTypeLike): The type of component (e.g., node)
|
|
255
|
+
attribute (AttributeType): The attribute whose empty value is required
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
np.ndarray: The empty value for the specified attribute
|
|
259
|
+
"""
|
|
260
|
+
data_type = _str_to_datatype(data_type)
|
|
261
|
+
component_type = _str_to_component_type(component_type)
|
|
262
|
+
return power_grid_meta_data[data_type][component_type].nan_scalar[attribute]
|