From 283fa68c0ee2e61de141bca7312b6a919c6f1443 Mon Sep 17 00:00:00 2001 From: Antoine Frau Date: Fri, 18 Mar 2022 18:00:13 +0000 Subject: [PATCH] Fix codejail numpy encoder for --- codejail/custom_encoder.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/codejail/custom_encoder.py b/codejail/custom_encoder.py index 98e624d16..3ce201a12 100644 --- a/codejail/custom_encoder.py +++ b/codejail/custom_encoder.py @@ -8,6 +8,7 @@ def default(self, obj): elif type(obj).__module__ == 'pandas': if hasattr(obj, 'to_json'): return obj.to_json(orient='records') + return repr(obj) return json.JSONEncoder.default(self, obj) @@ -28,6 +29,4 @@ def default(self, obj): return obj.tolist() elif isinstance(obj, (np.bool_)): return bool(obj) - elif isinstance(obj, (np.void)): - return None - return json.JSONEncoder.default(self, obj) + return repr(obj)