forked from platypush/platypush
Skip numpy types serialization errors on Message.Encoder.
This commit is contained in:
parent
e5a5ac5ffb
commit
9acd71944c
1 changed files with 14 additions and 14 deletions
|
@ -34,8 +34,6 @@ class Message:
|
||||||
def parse_numpy(obj):
|
def parse_numpy(obj):
|
||||||
try:
|
try:
|
||||||
import numpy as np
|
import numpy as np
|
||||||
except ImportError:
|
|
||||||
return
|
|
||||||
|
|
||||||
if isinstance(obj, np.floating):
|
if isinstance(obj, np.floating):
|
||||||
return float(obj)
|
return float(obj)
|
||||||
|
@ -49,6 +47,8 @@ class Message:
|
||||||
return '0x' + ''.join([f'{x:02x}' for x in obj])
|
return '0x' + ''.join([f'{x:02x}' for x in obj])
|
||||||
if callable(obj):
|
if callable(obj):
|
||||||
return '<function at {}.{}>'.format(obj.__module__, obj.__name__)
|
return '<function at {}.{}>'.format(obj.__module__, obj.__name__)
|
||||||
|
except (ImportError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue