|
21 | 21 | _str_to_datatype,
|
22 | 22 | )
|
23 | 23 | from power_grid_model._core.power_grid_core import AttributePtr, ComponentPtr, DatasetPtr, power_grid_core as pgc
|
24 |
| -from power_grid_model.data_types import DenseBatchArray, SingleArray |
| 24 | +from power_grid_model.data_types import AttributeType, DenseBatchArray, SingleArray |
25 | 25 |
|
26 | 26 |
|
27 | 27 | # constant enum for ctype
|
@@ -205,3 +205,41 @@ def initialize_array(
|
205 | 205 | dtype=power_grid_meta_data[data_type][component_type].dtype,
|
206 | 206 | order="C",
|
207 | 207 | )
|
| 208 | + |
| 209 | + |
| 210 | +def attribute_dtype( |
| 211 | + data_type: DatasetTypeLike, component_type: ComponentTypeLike, attribute: AttributeType |
| 212 | +) -> np.dtype: |
| 213 | + """Gives out dtype of the attribute to be used in a columnar data format |
| 214 | +
|
| 215 | + Args: |
| 216 | + data_type (DatasetTypeLike): The type of dataset (input, update, sym_output, or asym_output) |
| 217 | + component_type (ComponentTypeLike): The type of component (e.g., node) |
| 218 | + attribute (AttributeType): The attribute whose dtype is required |
| 219 | +
|
| 220 | + Returns: |
| 221 | + np.dtype: The dtype of the specified attribute |
| 222 | + """ |
| 223 | + data_type = _str_to_datatype(data_type) |
| 224 | + component_type = _str_to_component_type(component_type) |
| 225 | + return power_grid_meta_data[data_type][component_type].dtype[attribute] |
| 226 | + |
| 227 | + |
| 228 | +def attribute_empty_value( |
| 229 | + data_type: DatasetTypeLike, component_type: ComponentTypeLike, attribute: AttributeType |
| 230 | +) -> np.ndarray: |
| 231 | + """ |
| 232 | + Returns the empty value for a specific attribute in the Power Grid Model. |
| 233 | +
|
| 234 | +
|
| 235 | + Args: |
| 236 | + data_type (DatasetTypeLike): The type of dataset (input, update, sym_output, or asym_output) |
| 237 | + component_type (ComponentTypeLike): The type of component (e.g., node) |
| 238 | + attribute (AttributeType): The attribute whose empty value is required |
| 239 | +
|
| 240 | + Returns: |
| 241 | + np.ndarray: The empty value for the specified attribute |
| 242 | + """ |
| 243 | + data_type = _str_to_datatype(data_type) |
| 244 | + component_type = _str_to_component_type(component_type) |
| 245 | + return power_grid_meta_data[data_type][component_type].nan_scalar[attribute] |
0 commit comments