From 8a98bb157574eb30f0e8a713adde30a7fb03a5cb Mon Sep 17 00:00:00 2001 From: Jake VanderPlas Date: Thu, 14 Nov 2024 14:38:36 -0800 Subject: [PATCH] Avoid noisy JSON seralization warning for callables (e.g. numpy ufuncs) --- reporting.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reporting.py b/reporting.py index 63ac926e..579aa211 100644 --- a/reporting.py +++ b/reporting.py @@ -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.