bug fix/refactoring commong IEncoder
This commit is contained in:
parent
0cf56f3e8f
commit
6f7d912e20
|
@ -0,0 +1,17 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
class IEncoder (json.JSONEncoder):
|
||||||
|
def default (self,object):
|
||||||
|
if type(object) == np.integer :
|
||||||
|
return int(object)
|
||||||
|
elif type(object) == np.floating:
|
||||||
|
return float(object)
|
||||||
|
elif type(object) == np.ndarray :
|
||||||
|
return object.tolist()
|
||||||
|
elif type(object) == datetime :
|
||||||
|
return object.isoformat()
|
||||||
|
else:
|
||||||
|
return super(IEncoder,self).default(object)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,21 @@ import sys
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from multiprocessing import Lock, RLock
|
from multiprocessing import Lock, RLock
|
||||||
from transport.common import IEncoder
|
# from transport.common import IEncoder
|
||||||
|
|
||||||
|
class IEncoder (json.JSONEncoder):
|
||||||
|
def default (self,object):
|
||||||
|
if type(object) == np.integer :
|
||||||
|
return int(object)
|
||||||
|
elif type(object) == np.floating:
|
||||||
|
return float(object)
|
||||||
|
elif type(object) == np.ndarray :
|
||||||
|
return object.tolist()
|
||||||
|
elif type(object) == datetime :
|
||||||
|
return object.isoformat()
|
||||||
|
else:
|
||||||
|
return super(IEncoder,self).default(object)
|
||||||
|
|
||||||
|
|
||||||
class Mongo :
|
class Mongo :
|
||||||
lock = RLock()
|
lock = RLock()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import queue
|
import queue
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from transport.common import Reader,Writer
|
# from transport.common import Reader,Writer
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue