We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 044f5d7 commit 9120e6aCopy full SHA for 9120e6a
larch/utils/jsonutils.py
@@ -99,12 +99,11 @@ def encode4js(obj):
99
if obj is None:
100
return None
101
if isinstance(obj, np.ndarray):
102
+ out = {'__class__': 'Array', '__shape__': obj.shape}
103
try:
- out = {'__class__': 'Array', '__shape__': obj.shape,
104
- '__dtype__': obj.dtype.name}
+ out['__dtype__'] = obj.dtype.name
105
except:
106
- print('error encoding ndarray: ', obj, obj.shape, obj.dtype)
107
- out = {'__class__': 'Array', '__shape__': obj.shape}
+ out['__dtype__'] = 'object'
108
out['value'] = obj.flatten().tolist()
109
if 'complex' in obj.dtype.name:
110
out['value'] = [(obj.real).tolist(), (obj.imag).tolist()]
0 commit comments