MCPcopy Create free account
hub / github.com/PowerGridModel/power-grid-model / import_input_data

Function import_input_data

src/power_grid_model/utils.py:291–312  ·  view source on GitHub ↗

[deprecated] Import input json data. **WARNING:** This function is deprecated. Please use json_deserialize_from_file instead. For backwards and forward compatibility, this function supportes both the latest and the old serialization format. Args: json_file: path to the js

(json_file: Path)

Source from the content-addressed store, hash-verified

289
290
291def import_input_data(json_file: Path) -> SingleDataset: # pragma: no cover
292 """
293 [deprecated] Import input json data.
294
295 **WARNING:** This function is deprecated. Please use json_deserialize_from_file instead.
296
297 For backwards and forward compatibility, this function supportes both the latest and the old serialization format.
298
299 Args:
300 json_file: path to the json file.
301
302 Returns:
303 A single dataset for power-grid-model.
304 """
305 warnings.warn(_DEPRECATED_JSON_DESERIALIZATION_MSG, DeprecationWarning)
306
307 data = _compatibility_deprecated_import_json_data(json_file=json_file, data_type=DatasetType.input)
308 if not isinstance(data, dict):
309 raise TypeError(f"Expected data to be dict, got {type(data)}")
310 if not all(isinstance(component, np.ndarray) and component.ndim == 1 for component in data.values()):
311 raise TypeError("All components must be 1D numpy arrays")
312 return cast_type(SingleDataset, data)
313
314
315def import_update_data(json_file: Path) -> BatchDataset:

Callers

nothing calls this directly

Tested by

no test coverage detected