MCPcopy Create free account
hub / github.com/ahalev/python-microgrid / _arr_representer

Function _arr_representer

src/pymgrid/utils/serialize.py:83–91  ·  view source on GitHub ↗
(dumper, data, r_type)

Source from the content-addressed store, hash-verified

81
82
83def _arr_representer(dumper, data, r_type):
84 if hasattr(data, "path"):
85 rel_path = _dump_representation(data, data.path, Path(dumper.stream.name).parent)
86 return dumper.represent_scalar(f'!{r_type}', rel_path)
87
88 try:
89 return dumper.represent_mapping(f'!{r_type}', data.to_dict())
90 except AttributeError:
91 return dumper.represent_sequence(f'!{r_type}', data.tolist())
92
93
94def _dump_representation(data, path, stream_loc):

Callers 2

_numpy_arr_representerFunction · 0.85
_pandas_df_representerFunction · 0.85

Calls 2

_dump_representationFunction · 0.85
to_dictMethod · 0.45

Tested by

no test coverage detected