Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit 9e3cae8

Browse files
committed
Fix codejail numpy encoder for
1 parent 954acf0 commit 9e3cae8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

codejail/custom_encoder.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def default(self, obj):
88
elif type(obj).__module__ == 'pandas':
99
if hasattr(obj, 'to_json'):
1010
return obj.to_json(orient='records')
11+
return repr(obj)
1112
return json.JSONEncoder.default(self, obj)
1213

1314

@@ -28,6 +29,7 @@ def default(self, obj):
2829
return obj.tolist()
2930
elif isinstance(obj, (np.bool_)):
3031
return bool(obj)
31-
elif isinstance(obj, (np.void)):
32-
return None
33-
return json.JSONEncoder.default(self, obj)
32+
return repr(obj)
33+
34+
from numpy import matmul
35+
print(json.load(json.dumps("matmul", cls=GlobalEncoder, default=lambda o: repr(o))))

0 commit comments

Comments
 (0)