Skip to content

Commit

Permalink
Merge pull request #47 from silx-kit/str-ref
Browse files Browse the repository at this point in the history
Stringify RegionReference and Reference attributes
  • Loading branch information
loichuder authored Oct 26, 2021
2 parents f850941 + 7634566 commit e019d01
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion h5grove/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ 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]
if isinstance(o, h5py.Empty):
return None
if isinstance(o, bytes):
return o.decode()
if isinstance(o, (h5py.RegionReference, h5py.Reference)):
return str(o)
raise TypeError


Expand Down

0 comments on commit e019d01

Please sign in to comment.