From 763456612c216aec657e1da600064bc942dda725 Mon Sep 17 00:00:00 2001 From: Loic Huder Date: Tue, 26 Oct 2021 16:57:04 +0200 Subject: [PATCH] Stringify RegionReference and Reference attributes --- h5grove/encoders.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/h5grove/encoders.py b/h5grove/encoders.py index dd7685c..3a26193 100644 --- a/h5grove/encoders.py +++ b/h5grove/encoders.py @@ -21,7 +21,7 @@ def orjson_default(o) -> Union[list, str, None]: """Converts Python objects to JSON-serializable objects. :raises TypeError: if the object is not supported.""" - if isinstance(o, np.generic) or isinstance(o, np.ndarray): + if isinstance(o, (np.generic, np.ndarray)): return o.tolist() if isinstance(o, complex): return [o.real, o.imag] @@ -29,6 +29,8 @@ def orjson_default(o) -> Union[list, str, None]: return None if isinstance(o, bytes): return o.decode() + if isinstance(o, (h5py.RegionReference, h5py.Reference)): + return str(o) raise TypeError