Skip to content

Commit

Permalink
Avoid noisy JSON seralization warning for callables (e.g. numpy ufuncs)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Nov 14, 2024
1 parent 4bbe6be commit 8a98bb1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def to_json_serializable(o):
return tuple(to_json_serializable(i) for i in o)
if isinstance(o, list):
return [to_json_serializable(i) for i in o]
if callable(o):
return repr(o)

# Ensure everything is JSON serializable. If this warning is issued, it
# means the given type needs to be added above if possible.
Expand Down

0 comments on commit 8a98bb1

Please sign in to comment.