source:
framspy/evolalg/json_encoders.py
@
1309
Last change on this file since 1309 was 1190, checked in by , 21 months ago | |
---|---|
File size: 284 bytes |
Rev | Line | |
---|---|---|
[1190] | 1 | import json |
2 | ||
3 | import numpy as np | |
4 | ||
5 | ||
6 | class Encoder(json.JSONEncoder): | |
7 | def default(self, obj): | |
8 | if isinstance(obj, np.ndarray): | |
9 | return obj.tolist() | |
10 | if isinstance(obj, np.integer): | |
11 | return int(obj) | |
12 | return super(Encoder, self).default(obj) |
Note: See TracBrowser
for help on using the repository browser.