power-grid-model 1.11.33__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 -54
  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 -321
  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 -469
  54. power_grid_model/validation/__init__.py +25 -25
  55. power_grid_model/validation/_rules.py +1171 -1174
  56. power_grid_model/validation/_validation.py +1172 -1173
  57. power_grid_model/validation/assertions.py +93 -93
  58. power_grid_model/validation/errors.py +602 -589
  59. power_grid_model/validation/utils.py +313 -312
  60. {power_grid_model-1.11.33.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.33.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.33.dist-info/RECORD +0 -36
  66. power_grid_model-1.11.33.dist-info/top_level.txt +0 -1
  67. {power_grid_model-1.11.33.dist-info → power_grid_model-1.12.70.dist-info}/licenses/LICENSE +0 -0
@@ -1,581 +1,563 @@
1
- # SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
2
- #
3
- # SPDX-License-Identifier: MPL-2.0
4
-
5
- """
6
- Loader for the dynamic library
7
- """
8
-
9
- import os
10
- import platform
11
- from ctypes import CDLL, POINTER, c_char, c_char_p, c_double, c_size_t, c_void_p
12
- from inspect import signature
13
- from itertools import chain
14
- from pathlib import Path
15
- from typing import Callable
16
-
17
- from power_grid_model._core.index_integer import IdC, IdxC
18
-
19
- # integer index
20
- IdxPtr = POINTER(IdxC)
21
- """Pointer to index."""
22
- IdxDoublePtr = POINTER(IdxPtr)
23
- """Double pointer to index."""
24
- IDPtr = POINTER(IdC)
25
- """Raw pointer to ids."""
26
-
27
- # string data
28
- CStr = c_char_p
29
- """Null terminated string."""
30
- CStrPtr = POINTER(CStr)
31
- """Pointer to null terminated string."""
32
- CharPtr = POINTER(c_char)
33
- """Raw pointer to char."""
34
- CharDoublePtr = POINTER(CharPtr)
35
- """Double pointer to char."""
36
-
37
- # raw data
38
- VoidPtr = c_void_p
39
- """Raw void pointer."""
40
- VoidDoublePtr = POINTER(c_void_p)
41
- """Double pointer to void."""
42
-
43
- # functions with size_t return
44
- _FUNC_SIZE_T_RES = {"meta_class_size", "meta_class_alignment", "meta_attribute_offset"}
45
- _ARGS_TYPE_MAPPING = {bytes: CharPtr, str: CStr, int: IdxC, float: c_double}
46
-
47
- # The c_void_p is extended only for type hinting and type checking; therefore no public methods are required.
48
-
49
-
50
- class HandlePtr(c_void_p):
51
- """
52
- Pointer to handle
53
- """
54
-
55
-
56
- class OptionsPtr(c_void_p):
57
- """
58
- Pointer to option
59
- """
60
-
61
-
62
- class ModelPtr(c_void_p):
63
- """
64
- Pointer to model
65
- """
66
-
67
-
68
- class DatasetPtr(c_void_p):
69
- """
70
- Pointer to dataset
71
- """
72
-
73
-
74
- class ConstDatasetPtr(c_void_p):
75
- """
76
- Pointer to writable dataset
77
- """
78
-
79
-
80
- class MutableDatasetPtr(c_void_p):
81
- """
82
- Pointer to writable dataset
83
- """
84
-
85
-
86
- class WritableDatasetPtr(c_void_p):
87
- """
88
- Pointer to writable dataset
89
- """
90
-
91
-
92
- class DatasetInfoPtr(c_void_p):
93
- """
94
- Pointer to dataset info
95
- """
96
-
97
-
98
- class ComponentPtr(c_void_p):
99
- """
100
- Pointer to component
101
- """
102
-
103
-
104
- class AttributePtr(c_void_p):
105
- """
106
- Pointer to attribute
107
- """
108
-
109
-
110
- class DeserializerPtr(c_void_p):
111
- """
112
- Pointer to deserializer
113
- """
114
-
115
-
116
- class SerializerPtr(c_void_p):
117
- """
118
- Pointer to serializer
119
- """
120
-
121
-
122
- def _load_core() -> CDLL:
123
- """
124
-
125
- Returns: DLL/SO object
126
-
127
- """
128
- # first try to find the DLL local
129
- dll_file = "_power_grid_core.dll" if platform.system() == "Windows" else "_power_grid_core.so"
130
- dll_path = Path(__file__).parent / dll_file
131
-
132
- # if local DLL is not found, try to find the DLL from conda environment
133
- if (not dll_path.exists()) and ("CONDA_PREFIX" in os.environ):
134
- if platform.system() == "Windows":
135
- dll_file = "power_grid_model_c.dll"
136
- elif platform.system() == "Darwin":
137
- dll_file = "libpower_grid_model_c.dylib"
138
- elif platform.system() == "Linux":
139
- dll_file = "libpower_grid_model_c.so"
140
- else:
141
- raise NotImplementedError(f"Unsupported platform: {platform.system()}")
142
- # the dll will be found through conda environment
143
- dll_path = Path(dll_file)
144
-
145
- cdll = CDLL(str(dll_path))
146
- # assign return types
147
- # handle
148
- cdll.PGM_create_handle.argtypes = []
149
- cdll.PGM_create_handle.restype = HandlePtr
150
- cdll.PGM_destroy_handle.argtypes = [HandlePtr]
151
- cdll.PGM_destroy_handle.restype = None
152
- return cdll
153
-
154
-
155
- # load dll once
156
- _CDLL: CDLL = _load_core()
157
-
158
-
159
- def make_c_binding(func: Callable):
160
- """
161
- Descriptor to make the function to bind to C
162
-
163
- Args:
164
- func: method object from PowerGridCore
165
-
166
- Returns:
167
- Binded function
168
-
169
- """
170
- name = func.__name__
171
- sig = signature(func)
172
-
173
- # get and convert types, skip first argument, as it is self
174
- py_argnames = list(sig.parameters.keys())[1:]
175
- py_argtypes = [v.annotation for v in sig.parameters.values()][1:]
176
- py_restype = sig.return_annotation
177
- c_argtypes = [_ARGS_TYPE_MAPPING.get(x, x) for x in py_argtypes]
178
- c_restype = _ARGS_TYPE_MAPPING.get(py_restype, py_restype)
179
- if c_restype == IdxC and name in _FUNC_SIZE_T_RES:
180
- c_restype = c_size_t
181
- # set argument in dll
182
- # mostly with handle pointer, except destroy function
183
- is_destroy_func = "destroy" in name
184
- if is_destroy_func:
185
- getattr(_CDLL, f"PGM_{name}").argtypes = c_argtypes
186
- else:
187
- getattr(_CDLL, f"PGM_{name}").argtypes = [HandlePtr] + c_argtypes
188
- getattr(_CDLL, f"PGM_{name}").restype = c_restype
189
-
190
- # binding function
191
- def cbind_func(self, *args, **kwargs):
192
- c_inputs = [] if "destroy" in name else [self._handle]
193
- args = chain(args, (kwargs[key] for key in py_argnames[len(args) :]))
194
- for arg in args:
195
- if isinstance(arg, str):
196
- c_inputs.append(arg.encode())
197
- else:
198
- c_inputs.append(arg)
199
-
200
- # call
201
- res = getattr(_CDLL, f"PGM_{name}")(*c_inputs)
202
- # convert to string for CStr
203
- if c_restype == CStr:
204
- res = res.decode() if res is not None else ""
205
- return res
206
-
207
- return cbind_func
208
-
209
-
210
- class PowerGridCore:
211
- """
212
- DLL caller
213
- """
214
-
215
- _handle: HandlePtr
216
- _instance: "PowerGridCore | None" = None
217
-
218
- # singleton of power grid core
219
- def __new__(cls, *args, **kwargs):
220
- if cls._instance is None:
221
- cls._instance = super().__new__(cls, *args, **kwargs)
222
- cls._instance._handle = _CDLL.PGM_create_handle()
223
- return cls._instance
224
-
225
- def __del__(self):
226
- _CDLL.PGM_destroy_handle(self._handle)
227
-
228
- # not copyable
229
- def __copy__(self):
230
- raise NotImplementedError("Class not copyable")
231
-
232
- def __deepcopy__(self, memodict):
233
- raise NotImplementedError("class not copyable")
234
-
235
- @make_c_binding
236
- def error_code(self) -> int: # type: ignore[empty-body]
237
- pass # pragma: no cover
238
-
239
- @make_c_binding
240
- def error_message(self) -> str: # type: ignore[empty-body]
241
- pass # pragma: no cover
242
-
243
- @make_c_binding
244
- def n_failed_scenarios(self) -> int: # type: ignore[empty-body]
245
- pass # pragma: no cover
246
-
247
- @make_c_binding
248
- def failed_scenarios(self) -> IdxPtr: # type: ignore[empty-body, valid-type] # type: ignore[empty-body]
249
- pass # pragma: no cover
250
-
251
- @make_c_binding
252
- def batch_errors(self) -> CStrPtr: # type: ignore[empty-body, valid-type] # type: ignore[empty-body]
253
- pass # pragma: no cover
254
-
255
- @make_c_binding
256
- def clear_error(self) -> None: # type: ignore[empty-body]
257
- pass # pragma: no cover
258
-
259
- @make_c_binding
260
- def meta_n_datasets(self) -> int: # type: ignore[empty-body]
261
- pass # pragma: no cover
262
-
263
- @make_c_binding
264
- def meta_get_dataset_by_idx(self, idx: int) -> DatasetPtr: # type: ignore[empty-body]
265
- pass # pragma: no cover
266
-
267
- @make_c_binding
268
- def meta_dataset_name(self, dataset: DatasetPtr) -> str: # type: ignore[empty-body]
269
- pass # pragma: no cover
270
-
271
- @make_c_binding
272
- def meta_n_components(self, dataset: DatasetPtr) -> int: # type: ignore[empty-body]
273
- pass # pragma: no cover
274
-
275
- @make_c_binding
276
- def meta_get_component_by_idx(self, dataset: DatasetPtr, idx: int) -> ComponentPtr: # type: ignore[empty-body]
277
- pass # pragma: no cover
278
-
279
- @make_c_binding
280
- def meta_component_name(self, component: ComponentPtr) -> str: # type: ignore[empty-body]
281
- pass # pragma: no cover
282
-
283
- @make_c_binding
284
- def meta_component_alignment(self, component: ComponentPtr) -> int: # type: ignore[empty-body]
285
- pass # pragma: no cover
286
-
287
- @make_c_binding
288
- def meta_component_size(self, component: ComponentPtr) -> int: # type: ignore[empty-body]
289
- pass # pragma: no cover
290
-
291
- @make_c_binding
292
- def meta_n_attributes(self, component: ComponentPtr) -> int: # type: ignore[empty-body]
293
- pass # pragma: no cover
294
-
295
- @make_c_binding
296
- def meta_get_attribute_by_idx(self, component: ComponentPtr, idx: int) -> AttributePtr: # type: ignore[empty-body]
297
- pass # pragma: no cover
298
-
299
- @make_c_binding
300
- def meta_attribute_name(self, attribute: AttributePtr) -> str: # type: ignore[empty-body]
301
- pass # pragma: no cover
302
-
303
- @make_c_binding
304
- def meta_attribute_ctype(self, attribute: AttributePtr) -> int: # type: ignore[empty-body]
305
- pass # pragma: no cover
306
-
307
- @make_c_binding
308
- def meta_attribute_offset(self, attribute: AttributePtr) -> int: # type: ignore[empty-body]
309
- pass # pragma: no cover
310
-
311
- @make_c_binding
312
- def is_little_endian(self) -> int: # type: ignore[empty-body]
313
- pass # pragma: no cover
314
-
315
- @make_c_binding
316
- def create_options(self) -> OptionsPtr: # type: ignore[empty-body]
317
- pass # pragma: no cover
318
-
319
- @make_c_binding
320
- def destroy_options(self, opt: OptionsPtr) -> None: # type: ignore[empty-body]
321
- pass # pragma: no cover
322
-
323
- @make_c_binding
324
- def set_calculation_type(self, opt: OptionsPtr, calculation_type: int) -> None: # type: ignore[empty-body]
325
- pass # pragma: no cover
326
-
327
- @make_c_binding
328
- def set_calculation_method(self, opt: OptionsPtr, method: int) -> None: # type: ignore[empty-body]
329
- pass # pragma: no cover
330
-
331
- @make_c_binding
332
- def set_tap_changing_strategy(self, opt: OptionsPtr, tap_changing_strategy: int) -> None: # type: ignore[empty-body]
333
- pass # pragma: no cover
334
-
335
- @make_c_binding
336
- def set_short_circuit_voltage_scaling(self, opt: OptionsPtr, short_circuit_voltage_scaling: int) -> None: # type: ignore[empty-body]
337
- pass # pragma: no cover
338
-
339
- @make_c_binding
340
- def set_experimental_features(self, opt: OptionsPtr, experimental_features: int) -> None: # type: ignore[empty-body]
341
- pass # pragma: no cover
342
-
343
- @make_c_binding
344
- def set_symmetric(self, opt: OptionsPtr, sym: int) -> None: # type: ignore[empty-body]
345
- pass # pragma: no cover
346
-
347
- @make_c_binding
348
- def set_err_tol(self, opt: OptionsPtr, err_tol: float) -> None: # type: ignore[empty-body]
349
- pass # pragma: no cover
350
-
351
- @make_c_binding
352
- def set_max_iter(self, opt: OptionsPtr, max_iter: int) -> None: # type: ignore[empty-body]
353
- pass # pragma: no cover
354
-
355
- @make_c_binding
356
- def set_threading(self, opt: OptionsPtr, threading: int) -> None: # type: ignore[empty-body]
357
- pass # pragma: no cover
358
-
359
- @make_c_binding
360
- def create_model( # type: ignore[empty-body]
361
- self,
362
- system_frequency: float,
363
- input_data: ConstDatasetPtr, # type: ignore[valid-type]
364
- ) -> ModelPtr:
365
- pass # pragma: no cover
366
-
367
- @make_c_binding
368
- def update_model( # type: ignore[empty-body]
369
- self,
370
- model: ModelPtr,
371
- update_data: ConstDatasetPtr, # type: ignore[valid-type]
372
- ) -> None:
373
- pass # pragma: no cover
374
-
375
- @make_c_binding
376
- def copy_model(self, model: ModelPtr) -> ModelPtr: # type: ignore[empty-body]
377
- pass # pragma: no cover
378
-
379
- @make_c_binding
380
- def get_indexer(
381
- self,
382
- model: ModelPtr,
383
- component: str,
384
- size: int,
385
- ids: IDPtr, # type: ignore[valid-type]
386
- indexer: IdxPtr, # type: ignore[valid-type]
387
- ) -> None: # type: ignore[empty-body]
388
- pass # pragma: no cover
389
-
390
- @make_c_binding
391
- def destroy_model(self, model: ModelPtr) -> None: # type: ignore[empty-body]
392
- pass # pragma: no cover
393
-
394
- @make_c_binding
395
- def calculate( # type: ignore[empty-body]
396
- self,
397
- model: ModelPtr,
398
- opt: OptionsPtr,
399
- output_data: MutableDatasetPtr, # type: ignore[valid-type]
400
- update_data: ConstDatasetPtr, # type: ignore[valid-type]
401
- ) -> None:
402
- pass # pragma: no cover
403
-
404
- @make_c_binding
405
- def dataset_info_name(self, info: DatasetInfoPtr) -> str: # type: ignore[empty-body]
406
- pass # pragma: no cover
407
-
408
- @make_c_binding
409
- def dataset_info_is_batch(self, info: DatasetInfoPtr) -> int: # type: ignore[empty-body]
410
- pass # pragma: no cover
411
-
412
- @make_c_binding
413
- def dataset_info_batch_size(self, info: DatasetInfoPtr) -> int: # type: ignore[empty-body]
414
- pass # pragma: no cover
415
-
416
- @make_c_binding
417
- def dataset_info_n_components(self, info: DatasetInfoPtr) -> int: # type: ignore[empty-body]
418
- pass # pragma: no cover
419
-
420
- @make_c_binding
421
- def dataset_info_component_name(self, info: DatasetInfoPtr, component_idx: int) -> str: # type: ignore[empty-body]
422
- pass # pragma: no cover
423
-
424
- @make_c_binding
425
- def dataset_info_elements_per_scenario( # type: ignore[empty-body]
426
- self, info: DatasetInfoPtr, component_idx: int
427
- ) -> int:
428
- pass # pragma: no cover
429
-
430
- @make_c_binding
431
- def dataset_info_total_elements(self, info: DatasetInfoPtr, component_idx: int) -> int: # type: ignore[empty-body]
432
- pass # pragma: no cover
433
-
434
- @make_c_binding
435
- def dataset_info_has_attribute_indications( # type: ignore[empty-body]
436
- self, info: DatasetInfoPtr, component_idx: int
437
- ) -> int:
438
- pass # pragma: no cover
439
-
440
- @make_c_binding
441
- def dataset_info_n_attribute_indications( # type: ignore[empty-body]
442
- self, info: DatasetInfoPtr, component_idx: int
443
- ) -> int:
444
- pass # pragma: no cover
445
-
446
- @make_c_binding
447
- def dataset_info_attribute_name( # type: ignore[empty-body]
448
- self, info: DatasetInfoPtr, component_idx: int, attribute_idx: int
449
- ) -> str:
450
- pass # pragma: no cover
451
-
452
- @make_c_binding
453
- def create_dataset_mutable( # type: ignore[empty-body]
454
- self, dataset: str, is_batch: int, batch_size: int
455
- ) -> MutableDatasetPtr:
456
- pass # pragma: no cover
457
-
458
- @make_c_binding
459
- def destroy_dataset_mutable(self, dataset: MutableDatasetPtr) -> None: # type: ignore[empty-body]
460
- pass # pragma: no cover
461
-
462
- @make_c_binding
463
- def dataset_mutable_add_buffer( # type: ignore[empty-body]
464
- self,
465
- dataset: MutableDatasetPtr,
466
- component: str,
467
- elements_per_scenario: int,
468
- total_elements: int,
469
- indptr: IdxPtr, # type: ignore[valid-type]
470
- data: VoidPtr, # type: ignore[valid-type]
471
- ) -> None:
472
- pass # pragma: no cover
473
-
474
- @make_c_binding
475
- def dataset_mutable_add_attribute_buffer(
476
- self,
477
- dataset: MutableDatasetPtr,
478
- component: str,
479
- attribute: str,
480
- data: VoidPtr, # type: ignore[valid-type]
481
- ) -> None: # type: ignore[empty-body]
482
- pass # pragma: no cover
483
-
484
- @make_c_binding
485
- def dataset_mutable_get_info(self, dataset: MutableDatasetPtr) -> DatasetInfoPtr: # type: ignore[empty-body]
486
- pass # pragma: no cover
487
-
488
- @make_c_binding
489
- def create_dataset_const_from_mutable( # type: ignore[empty-body]
490
- self, mutable_dataset: MutableDatasetPtr
491
- ) -> ConstDatasetPtr:
492
- pass # pragma: no cover
493
-
494
- @make_c_binding
495
- def destroy_dataset_const(self, dataset: ConstDatasetPtr) -> None: # type: ignore[empty-body]
496
- pass # pragma: no cover
497
-
498
- @make_c_binding
499
- def dataset_const_get_info(self, dataset: ConstDatasetPtr) -> DatasetInfoPtr: # type: ignore[empty-body]
500
- pass # pragma: no cover
501
-
502
- @make_c_binding
503
- def dataset_writable_get_info(self, dataset: WritableDatasetPtr) -> DatasetInfoPtr: # type: ignore[empty-body]
504
- pass # pragma: no cover
505
-
506
- @make_c_binding
507
- def dataset_writable_set_buffer(
508
- self,
509
- dataset: WritableDatasetPtr,
510
- component: str,
511
- indptr: IdxPtr, # type: ignore[valid-type]
512
- data: VoidPtr, # type: ignore[valid-type]
513
- ) -> None: # type: ignore[empty-body]
514
- pass # pragma: no cover
515
-
516
- @make_c_binding
517
- def dataset_writable_set_attribute_buffer(
518
- self,
519
- dataset: WritableDatasetPtr,
520
- component: str,
521
- attribute: str,
522
- data: VoidPtr, # type: ignore[valid-type]
523
- ) -> None: # type: ignore[empty-body]
524
- pass # pragma: no cover
525
-
526
- @make_c_binding
527
- def create_deserializer_from_binary_buffer( # type: ignore[empty-body]
528
- self, data: bytes, size: int, serialization_format: int
529
- ) -> DeserializerPtr:
530
- pass # pragma: no cover
531
-
532
- @make_c_binding
533
- def create_deserializer_from_null_terminated_string( # type: ignore[empty-body]
534
- self, data: str, serialization_format: int
535
- ) -> DeserializerPtr:
536
- pass # pragma: no cover
537
-
538
- @make_c_binding
539
- def deserializer_get_dataset(self, deserializer: DeserializerPtr) -> WritableDatasetPtr: # type: ignore[empty-body]
540
- pass # pragma: no cover
541
-
542
- @make_c_binding
543
- def deserializer_parse_to_buffer(self, deserializer: DeserializerPtr) -> None: # type: ignore[empty-body]
544
- pass # pragma: no cover
545
-
546
- @make_c_binding
547
- def destroy_deserializer(self, deserializer: DeserializerPtr) -> None: # type: ignore[empty-body]
548
- pass # pragma: no cover
549
-
550
- @make_c_binding
551
- def create_serializer( # type: ignore[empty-body]
552
- self, data: ConstDatasetPtr, serialization_format: int
553
- ) -> SerializerPtr:
554
- pass # pragma: no cover
555
-
556
- @make_c_binding
557
- def serializer_get_to_binary_buffer( # type: ignore[empty-body]
558
- self,
559
- serializer: SerializerPtr,
560
- use_compact_list: int,
561
- data: CharDoublePtr, # type: ignore[valid-type]
562
- size: IdxPtr, # type: ignore[valid-type]
563
- ) -> None:
564
- pass # pragma: no cover
565
-
566
- @make_c_binding
567
- def serializer_get_to_zero_terminated_string( # type: ignore[empty-body]
568
- self,
569
- serializer: SerializerPtr,
570
- use_compact_list: int,
571
- indent: int,
572
- ) -> str:
573
- pass # pragma: no cover
574
-
575
- @make_c_binding
576
- def destroy_serializer(self, serializer: SerializerPtr) -> None: # type: ignore[empty-body]
577
- pass # pragma: no cover
578
-
579
-
580
- # make one instance
581
- power_grid_core = PowerGridCore()
1
+ # SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
2
+ #
3
+ # SPDX-License-Identifier: MPL-2.0
4
+
5
+ """
6
+ Loader for the dynamic library
7
+ """
8
+
9
+ from collections.abc import Callable
10
+ from ctypes import CDLL, POINTER, c_char, c_char_p, c_double, c_size_t, c_void_p
11
+ from inspect import signature
12
+ from itertools import chain
13
+
14
+ from power_grid_model._core.index_integer import IdC, IdxC
15
+ from power_grid_model._core.power_grid_model_c.get_pgm_dll_path import get_pgm_dll_path
16
+
17
+ # integer index
18
+ IdxPtr = POINTER(IdxC)
19
+ """Pointer to index."""
20
+ IdxDoublePtr = POINTER(IdxPtr)
21
+ """Double pointer to index."""
22
+ IDPtr = POINTER(IdC)
23
+ """Raw pointer to ids."""
24
+
25
+ # string data
26
+ CStr = c_char_p
27
+ """Null terminated string."""
28
+ CStrPtr = POINTER(CStr)
29
+ """Pointer to null terminated string."""
30
+ CharPtr = POINTER(c_char)
31
+ """Raw pointer to char."""
32
+ CharDoublePtr = POINTER(CharPtr)
33
+ """Double pointer to char."""
34
+
35
+ # raw data
36
+ VoidPtr = c_void_p
37
+ """Raw void pointer."""
38
+ VoidDoublePtr = POINTER(c_void_p)
39
+ """Double pointer to void."""
40
+
41
+ # functions with size_t return
42
+ _FUNC_SIZE_T_RES = {"meta_class_size", "meta_class_alignment", "meta_attribute_offset"}
43
+ _ARGS_TYPE_MAPPING = {bytes: CharPtr, str: CStr, int: IdxC, float: c_double}
44
+
45
+ # The c_void_p is extended only for type hinting and type checking; therefore no public methods are required.
46
+
47
+
48
+ class HandlePtr(c_void_p):
49
+ """
50
+ Pointer to handle
51
+ """
52
+
53
+
54
+ class OptionsPtr(c_void_p):
55
+ """
56
+ Pointer to option
57
+ """
58
+
59
+
60
+ class ModelPtr(c_void_p):
61
+ """
62
+ Pointer to model
63
+ """
64
+
65
+
66
+ class DatasetPtr(c_void_p):
67
+ """
68
+ Pointer to dataset
69
+ """
70
+
71
+
72
+ class ConstDatasetPtr(c_void_p):
73
+ """
74
+ Pointer to writable dataset
75
+ """
76
+
77
+
78
+ class MutableDatasetPtr(c_void_p):
79
+ """
80
+ Pointer to writable dataset
81
+ """
82
+
83
+
84
+ class WritableDatasetPtr(c_void_p):
85
+ """
86
+ Pointer to writable dataset
87
+ """
88
+
89
+
90
+ class DatasetInfoPtr(c_void_p):
91
+ """
92
+ Pointer to dataset info
93
+ """
94
+
95
+
96
+ class ComponentPtr(c_void_p):
97
+ """
98
+ Pointer to component
99
+ """
100
+
101
+
102
+ class AttributePtr(c_void_p):
103
+ """
104
+ Pointer to attribute
105
+ """
106
+
107
+
108
+ class DeserializerPtr(c_void_p):
109
+ """
110
+ Pointer to deserializer
111
+ """
112
+
113
+
114
+ class SerializerPtr(c_void_p):
115
+ """
116
+ Pointer to serializer
117
+ """
118
+
119
+
120
+ def _load_core() -> CDLL:
121
+ """
122
+
123
+ Returns: DLL/SO object
124
+
125
+ """
126
+ dll_path = get_pgm_dll_path()
127
+ cdll = CDLL(str(dll_path))
128
+ # assign return types
129
+ # handle
130
+ cdll.PGM_create_handle.argtypes = []
131
+ cdll.PGM_create_handle.restype = HandlePtr
132
+ cdll.PGM_destroy_handle.argtypes = [HandlePtr]
133
+ cdll.PGM_destroy_handle.restype = None
134
+ return cdll
135
+
136
+
137
+ # load dll once
138
+ _CDLL: CDLL = _load_core()
139
+
140
+
141
+ def make_c_binding(func: Callable):
142
+ """
143
+ Descriptor to make the function to bind to C
144
+
145
+ Args:
146
+ func: method object from PowerGridCore
147
+
148
+ Returns:
149
+ Binded function
150
+
151
+ """
152
+ name = func.__name__
153
+ sig = signature(func)
154
+
155
+ # get and convert types, skip first argument, as it is self
156
+ py_argnames = list(sig.parameters.keys())[1:]
157
+ py_argtypes = [v.annotation for v in sig.parameters.values()][1:]
158
+ py_restype = sig.return_annotation
159
+ c_argtypes = [_ARGS_TYPE_MAPPING.get(x, x) for x in py_argtypes]
160
+ c_restype = _ARGS_TYPE_MAPPING.get(py_restype, py_restype)
161
+ if c_restype == IdxC and name in _FUNC_SIZE_T_RES:
162
+ c_restype = c_size_t
163
+ # set argument in dll
164
+ # mostly with handle pointer, except destroy function
165
+ is_destroy_func = "destroy" in name
166
+ if is_destroy_func:
167
+ getattr(_CDLL, f"PGM_{name}").argtypes = c_argtypes
168
+ else:
169
+ getattr(_CDLL, f"PGM_{name}").argtypes = [HandlePtr, *c_argtypes]
170
+ getattr(_CDLL, f"PGM_{name}").restype = c_restype
171
+
172
+ # binding function
173
+ def cbind_func(self, *args, **kwargs):
174
+ c_inputs = [] if "destroy" in name else [self._handle]
175
+ args = chain(args, (kwargs[key] for key in py_argnames[len(args) :]))
176
+ for arg in args:
177
+ if isinstance(arg, str):
178
+ c_inputs.append(arg.encode())
179
+ else:
180
+ c_inputs.append(arg)
181
+
182
+ # call
183
+ res = getattr(_CDLL, f"PGM_{name}")(*c_inputs)
184
+ # convert to string for CStr
185
+ if c_restype == CStr:
186
+ res = res.decode() if res is not None else ""
187
+ return res
188
+
189
+ return cbind_func
190
+
191
+
192
+ class PowerGridCore:
193
+ """
194
+ DLL caller
195
+ """
196
+
197
+ _handle: HandlePtr
198
+ _instance: "PowerGridCore | None" = None
199
+
200
+ # singleton of power grid core
201
+ def __new__(cls, *args, **kwargs):
202
+ if cls._instance is None:
203
+ cls._instance = super().__new__(cls, *args, **kwargs)
204
+ cls._instance._handle = _CDLL.PGM_create_handle()
205
+ return cls._instance
206
+
207
+ def __del__(self):
208
+ _CDLL.PGM_destroy_handle(self._handle)
209
+
210
+ # not copyable
211
+ def __copy__(self):
212
+ raise NotImplementedError("Class not copyable")
213
+
214
+ def __deepcopy__(self, memodict):
215
+ raise NotImplementedError("class not copyable")
216
+
217
+ @make_c_binding
218
+ def error_code(self) -> int: # type: ignore[empty-body]
219
+ pass # pragma: no cover
220
+
221
+ @make_c_binding
222
+ def error_message(self) -> str: # type: ignore[empty-body]
223
+ pass # pragma: no cover
224
+
225
+ @make_c_binding
226
+ def n_failed_scenarios(self) -> int: # type: ignore[empty-body]
227
+ pass # pragma: no cover
228
+
229
+ @make_c_binding
230
+ def failed_scenarios(self) -> IdxPtr: # type: ignore[empty-body, valid-type] # type: ignore[empty-body]
231
+ pass # pragma: no cover
232
+
233
+ @make_c_binding
234
+ def batch_errors(self) -> CStrPtr: # type: ignore[empty-body, valid-type] # type: ignore[empty-body]
235
+ pass # pragma: no cover
236
+
237
+ @make_c_binding
238
+ def clear_error(self) -> None: # type: ignore[empty-body]
239
+ pass # pragma: no cover
240
+
241
+ @make_c_binding
242
+ def meta_n_datasets(self) -> int: # type: ignore[empty-body]
243
+ pass # pragma: no cover
244
+
245
+ @make_c_binding
246
+ def meta_get_dataset_by_idx(self, idx: int) -> DatasetPtr: # type: ignore[empty-body]
247
+ pass # pragma: no cover
248
+
249
+ @make_c_binding
250
+ def meta_dataset_name(self, dataset: DatasetPtr) -> str: # type: ignore[empty-body]
251
+ pass # pragma: no cover
252
+
253
+ @make_c_binding
254
+ def meta_n_components(self, dataset: DatasetPtr) -> int: # type: ignore[empty-body]
255
+ pass # pragma: no cover
256
+
257
+ @make_c_binding
258
+ def meta_get_component_by_idx(self, dataset: DatasetPtr, idx: int) -> ComponentPtr: # type: ignore[empty-body]
259
+ pass # pragma: no cover
260
+
261
+ @make_c_binding
262
+ def meta_component_name(self, component: ComponentPtr) -> str: # type: ignore[empty-body]
263
+ pass # pragma: no cover
264
+
265
+ @make_c_binding
266
+ def meta_component_alignment(self, component: ComponentPtr) -> int: # type: ignore[empty-body]
267
+ pass # pragma: no cover
268
+
269
+ @make_c_binding
270
+ def meta_component_size(self, component: ComponentPtr) -> int: # type: ignore[empty-body]
271
+ pass # pragma: no cover
272
+
273
+ @make_c_binding
274
+ def meta_n_attributes(self, component: ComponentPtr) -> int: # type: ignore[empty-body]
275
+ pass # pragma: no cover
276
+
277
+ @make_c_binding
278
+ def meta_get_attribute_by_idx(self, component: ComponentPtr, idx: int) -> AttributePtr: # type: ignore[empty-body]
279
+ pass # pragma: no cover
280
+
281
+ @make_c_binding
282
+ def meta_attribute_name(self, attribute: AttributePtr) -> str: # type: ignore[empty-body]
283
+ pass # pragma: no cover
284
+
285
+ @make_c_binding
286
+ def meta_attribute_ctype(self, attribute: AttributePtr) -> int: # type: ignore[empty-body]
287
+ pass # pragma: no cover
288
+
289
+ @make_c_binding
290
+ def meta_attribute_offset(self, attribute: AttributePtr) -> int: # type: ignore[empty-body]
291
+ pass # pragma: no cover
292
+
293
+ @make_c_binding
294
+ def is_little_endian(self) -> int: # type: ignore[empty-body]
295
+ pass # pragma: no cover
296
+
297
+ @make_c_binding
298
+ def create_options(self) -> OptionsPtr: # type: ignore[empty-body]
299
+ pass # pragma: no cover
300
+
301
+ @make_c_binding
302
+ def destroy_options(self, opt: OptionsPtr) -> None: # type: ignore[empty-body]
303
+ pass # pragma: no cover
304
+
305
+ @make_c_binding
306
+ def set_calculation_type(self, opt: OptionsPtr, calculation_type: int) -> None: # type: ignore[empty-body]
307
+ pass # pragma: no cover
308
+
309
+ @make_c_binding
310
+ def set_calculation_method(self, opt: OptionsPtr, method: int) -> None: # type: ignore[empty-body]
311
+ pass # pragma: no cover
312
+
313
+ @make_c_binding
314
+ def set_tap_changing_strategy(self, opt: OptionsPtr, tap_changing_strategy: int) -> None: # type: ignore[empty-body]
315
+ pass # pragma: no cover
316
+
317
+ @make_c_binding
318
+ def set_short_circuit_voltage_scaling(self, opt: OptionsPtr, short_circuit_voltage_scaling: int) -> None: # type: ignore[empty-body]
319
+ pass # pragma: no cover
320
+
321
+ @make_c_binding
322
+ def set_experimental_features(self, opt: OptionsPtr, experimental_features: int) -> None: # type: ignore[empty-body]
323
+ pass # pragma: no cover
324
+
325
+ @make_c_binding
326
+ def set_symmetric(self, opt: OptionsPtr, sym: int) -> None: # type: ignore[empty-body]
327
+ pass # pragma: no cover
328
+
329
+ @make_c_binding
330
+ def set_err_tol(self, opt: OptionsPtr, err_tol: float) -> None: # type: ignore[empty-body]
331
+ pass # pragma: no cover
332
+
333
+ @make_c_binding
334
+ def set_max_iter(self, opt: OptionsPtr, max_iter: int) -> None: # type: ignore[empty-body]
335
+ pass # pragma: no cover
336
+
337
+ @make_c_binding
338
+ def set_threading(self, opt: OptionsPtr, threading: int) -> None: # type: ignore[empty-body]
339
+ pass # pragma: no cover
340
+
341
+ @make_c_binding
342
+ def create_model( # type: ignore[empty-body]
343
+ self,
344
+ system_frequency: float,
345
+ input_data: ConstDatasetPtr, # type: ignore[valid-type]
346
+ ) -> ModelPtr:
347
+ pass # pragma: no cover
348
+
349
+ @make_c_binding
350
+ def update_model( # type: ignore[empty-body]
351
+ self,
352
+ model: ModelPtr,
353
+ update_data: ConstDatasetPtr, # type: ignore[valid-type]
354
+ ) -> None:
355
+ pass # pragma: no cover
356
+
357
+ @make_c_binding
358
+ def copy_model(self, model: ModelPtr) -> ModelPtr: # type: ignore[empty-body]
359
+ pass # pragma: no cover
360
+
361
+ @make_c_binding
362
+ def get_indexer(
363
+ self,
364
+ model: ModelPtr,
365
+ component: str,
366
+ size: int,
367
+ ids: IDPtr, # type: ignore[valid-type]
368
+ indexer: IdxPtr, # type: ignore[valid-type]
369
+ ) -> None: # type: ignore[empty-body]
370
+ pass # pragma: no cover
371
+
372
+ @make_c_binding
373
+ def destroy_model(self, model: ModelPtr) -> None: # type: ignore[empty-body]
374
+ pass # pragma: no cover
375
+
376
+ @make_c_binding
377
+ def calculate( # type: ignore[empty-body]
378
+ self,
379
+ model: ModelPtr,
380
+ opt: OptionsPtr,
381
+ output_data: MutableDatasetPtr, # type: ignore[valid-type]
382
+ update_data: ConstDatasetPtr, # type: ignore[valid-type]
383
+ ) -> None:
384
+ pass # pragma: no cover
385
+
386
+ @make_c_binding
387
+ def dataset_info_name(self, info: DatasetInfoPtr) -> str: # type: ignore[empty-body]
388
+ pass # pragma: no cover
389
+
390
+ @make_c_binding
391
+ def dataset_info_is_batch(self, info: DatasetInfoPtr) -> int: # type: ignore[empty-body]
392
+ pass # pragma: no cover
393
+
394
+ @make_c_binding
395
+ def dataset_info_batch_size(self, info: DatasetInfoPtr) -> int: # type: ignore[empty-body]
396
+ pass # pragma: no cover
397
+
398
+ @make_c_binding
399
+ def dataset_info_n_components(self, info: DatasetInfoPtr) -> int: # type: ignore[empty-body]
400
+ pass # pragma: no cover
401
+
402
+ @make_c_binding
403
+ def dataset_info_component_name(self, info: DatasetInfoPtr, component_idx: int) -> str: # type: ignore[empty-body]
404
+ pass # pragma: no cover
405
+
406
+ @make_c_binding
407
+ def dataset_info_elements_per_scenario( # type: ignore[empty-body]
408
+ self, info: DatasetInfoPtr, component_idx: int
409
+ ) -> int:
410
+ pass # pragma: no cover
411
+
412
+ @make_c_binding
413
+ def dataset_info_total_elements(self, info: DatasetInfoPtr, component_idx: int) -> int: # type: ignore[empty-body]
414
+ pass # pragma: no cover
415
+
416
+ @make_c_binding
417
+ def dataset_info_has_attribute_indications( # type: ignore[empty-body]
418
+ self, info: DatasetInfoPtr, component_idx: int
419
+ ) -> int:
420
+ pass # pragma: no cover
421
+
422
+ @make_c_binding
423
+ def dataset_info_n_attribute_indications( # type: ignore[empty-body]
424
+ self, info: DatasetInfoPtr, component_idx: int
425
+ ) -> int:
426
+ pass # pragma: no cover
427
+
428
+ @make_c_binding
429
+ def dataset_info_attribute_name( # type: ignore[empty-body]
430
+ self, info: DatasetInfoPtr, component_idx: int, attribute_idx: int
431
+ ) -> str:
432
+ pass # pragma: no cover
433
+
434
+ @make_c_binding
435
+ def create_dataset_mutable( # type: ignore[empty-body]
436
+ self, dataset: str, is_batch: int, batch_size: int
437
+ ) -> MutableDatasetPtr:
438
+ pass # pragma: no cover
439
+
440
+ @make_c_binding
441
+ def destroy_dataset_mutable(self, dataset: MutableDatasetPtr) -> None: # type: ignore[empty-body]
442
+ pass # pragma: no cover
443
+
444
+ @make_c_binding
445
+ def dataset_mutable_add_buffer( # type: ignore[empty-body] # noqa: PLR0913
446
+ self,
447
+ dataset: MutableDatasetPtr,
448
+ component: str,
449
+ elements_per_scenario: int,
450
+ total_elements: int,
451
+ indptr: IdxPtr, # type: ignore[valid-type]
452
+ data: VoidPtr, # type: ignore[valid-type]
453
+ ) -> None:
454
+ pass # pragma: no cover
455
+
456
+ @make_c_binding
457
+ def dataset_mutable_add_attribute_buffer(
458
+ self,
459
+ dataset: MutableDatasetPtr,
460
+ component: str,
461
+ attribute: str,
462
+ data: VoidPtr, # type: ignore[valid-type]
463
+ ) -> None: # type: ignore[empty-body]
464
+ pass # pragma: no cover
465
+
466
+ @make_c_binding
467
+ def dataset_mutable_get_info(self, dataset: MutableDatasetPtr) -> DatasetInfoPtr: # type: ignore[empty-body]
468
+ pass # pragma: no cover
469
+
470
+ @make_c_binding
471
+ def create_dataset_const_from_mutable( # type: ignore[empty-body]
472
+ self, mutable_dataset: MutableDatasetPtr
473
+ ) -> ConstDatasetPtr:
474
+ pass # pragma: no cover
475
+
476
+ @make_c_binding
477
+ def destroy_dataset_const(self, dataset: ConstDatasetPtr) -> None: # type: ignore[empty-body]
478
+ pass # pragma: no cover
479
+
480
+ @make_c_binding
481
+ def dataset_const_get_info(self, dataset: ConstDatasetPtr) -> DatasetInfoPtr: # type: ignore[empty-body]
482
+ pass # pragma: no cover
483
+
484
+ @make_c_binding
485
+ def dataset_writable_get_info(self, dataset: WritableDatasetPtr) -> DatasetInfoPtr: # type: ignore[empty-body]
486
+ pass # pragma: no cover
487
+
488
+ @make_c_binding
489
+ def dataset_writable_set_buffer(
490
+ self,
491
+ dataset: WritableDatasetPtr,
492
+ component: str,
493
+ indptr: IdxPtr, # type: ignore[valid-type]
494
+ data: VoidPtr, # type: ignore[valid-type]
495
+ ) -> None: # type: ignore[empty-body]
496
+ pass # pragma: no cover
497
+
498
+ @make_c_binding
499
+ def dataset_writable_set_attribute_buffer(
500
+ self,
501
+ dataset: WritableDatasetPtr,
502
+ component: str,
503
+ attribute: str,
504
+ data: VoidPtr, # type: ignore[valid-type]
505
+ ) -> None: # type: ignore[empty-body]
506
+ pass # pragma: no cover
507
+
508
+ @make_c_binding
509
+ def create_deserializer_from_binary_buffer( # type: ignore[empty-body]
510
+ self, data: bytes, size: int, serialization_format: int
511
+ ) -> DeserializerPtr:
512
+ pass # pragma: no cover
513
+
514
+ @make_c_binding
515
+ def create_deserializer_from_null_terminated_string( # type: ignore[empty-body]
516
+ self, data: str, serialization_format: int
517
+ ) -> DeserializerPtr:
518
+ pass # pragma: no cover
519
+
520
+ @make_c_binding
521
+ def deserializer_get_dataset(self, deserializer: DeserializerPtr) -> WritableDatasetPtr: # type: ignore[empty-body]
522
+ pass # pragma: no cover
523
+
524
+ @make_c_binding
525
+ def deserializer_parse_to_buffer(self, deserializer: DeserializerPtr) -> None: # type: ignore[empty-body]
526
+ pass # pragma: no cover
527
+
528
+ @make_c_binding
529
+ def destroy_deserializer(self, deserializer: DeserializerPtr) -> None: # type: ignore[empty-body]
530
+ pass # pragma: no cover
531
+
532
+ @make_c_binding
533
+ def create_serializer( # type: ignore[empty-body]
534
+ self, data: ConstDatasetPtr, serialization_format: int
535
+ ) -> SerializerPtr:
536
+ pass # pragma: no cover
537
+
538
+ @make_c_binding
539
+ def serializer_get_to_binary_buffer( # type: ignore[empty-body]
540
+ self,
541
+ serializer: SerializerPtr,
542
+ use_compact_list: int,
543
+ data: CharDoublePtr, # type: ignore[valid-type]
544
+ size: IdxPtr, # type: ignore[valid-type]
545
+ ) -> None:
546
+ pass # pragma: no cover
547
+
548
+ @make_c_binding
549
+ def serializer_get_to_zero_terminated_string( # type: ignore[empty-body]
550
+ self,
551
+ serializer: SerializerPtr,
552
+ use_compact_list: int,
553
+ indent: int,
554
+ ) -> str:
555
+ pass # pragma: no cover
556
+
557
+ @make_c_binding
558
+ def destroy_serializer(self, serializer: SerializerPtr) -> None: # type: ignore[empty-body]
559
+ pass # pragma: no cover
560
+
561
+
562
+ # make one instance
563
+ power_grid_core = PowerGridCore()