source: framspy/evolalg/json_encoders.py @ 1288

Last change on this file since 1288 was 1190, checked in by Maciej Komosinski, 2 years ago

Added the "evolalg" module for evolutionary optimization

File size: 284 bytes
Line 
1import json
2
3import numpy as np
4
5
6class 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.