MCPcopy
hub / github.com/mne-tools/mne-python / _serialize

Function _serialize

mne/preprocessing/ica.py:2911–2933  ·  view source on GitHub ↗

Aux function.

(dict_, outer_sep=";", inner_sep=":")

Source from the content-addressed store, hash-verified

2909
2910
2911def _serialize(dict_, outer_sep=";", inner_sep=":"):
2912 """Aux function."""
2913 s = []
2914 for key, value in dict_.items():
2915 if callable(value):
2916 value = value.__name__
2917 elif isinstance(value, Integral):
2918 value = int(value)
2919 elif isinstance(value, dict):
2920 # py35 json does not support numpy int64
2921 for subkey, subvalue in value.items():
2922 if isinstance(subvalue, list):
2923 if len(subvalue) > 0:
2924 if isinstance(subvalue[0], int | np.integer):
2925 value[subkey] = [int(i) for i in subvalue]
2926
2927 for cls in (np.random.RandomState, Covariance):
2928 if isinstance(value, cls):
2929 value = cls.__name__
2930
2931 s.append(key + inner_sep + json.dumps(value))
2932
2933 return outer_sep.join(s)
2934
2935
2936def _deserialize(str_, outer_sep=";", inner_sep=":"):

Callers 1

_write_icaFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected