You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found these strange corner cases when serializing np.float32 and np.int64 values. What's strange is that np.int32 and np.float64 for the same underlying value works.
Any ideas whats going on? ❓
importmsgpackimportnumpyasnpIn [1]: np.__version__Out[1]: '1.9.2'In [2]: msgpack.versionOut[2]: (0, 4, 6)
In [3]: msgpack.packb([np.float32(1213771)])
---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
<ipython-input-3-a34bd885d43f>in<module>()
---->1msgpack.packb([np.float32(1213771)])
D:\Python27\lib\site-packages\msgpack\__init__.pycinpackb(o, **kwargs)
45See :class:`Packer`foroptions.
46"""---> 47 return Packer(**kwargs).pack(o) 48 49 # alias for compatibility to simplejson/marshal/pickle.msgpack\_packer.pyx in msgpack._packer.Packer.pack (msgpack\_packer.cpp:223)()msgpack\_packer.pyx in msgpack._packer.Packer.pack (msgpack\_packer.cpp:225)()msgpack\_packer.pyx in msgpack._packer.Packer._pack (msgpack\_packer.cpp:213)()msgpack\_packer.pyx in msgpack._packer.Packer._pack (msgpack\_packer.cpp:220)()TypeError: can't serialize 1213771.0In [4]: msgpack.packb([np.int64(1213771)])---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-4-dc4780e7a01d> in <module>()----> 1 msgpack.packb([np.int64(1213771)])D:\Python27\lib\site-packages\msgpack\__init__.pyc in packb(o, **kwargs) 45 See :class:`Packer` for options. 46 """--->47returnPacker(**kwargs).pack(o)
4849# alias for compatibility to simplejson/marshal/pickle.msgpack\_packer.pyxinmsgpack._packer.Packer.pack (msgpack\_packer.cpp:223)()
msgpack\_packer.pyxinmsgpack._packer.Packer.pack (msgpack\_packer.cpp:225)()
msgpack\_packer.pyxinmsgpack._packer.Packer._pack (msgpack\_packer.cpp:213)()
msgpack\_packer.pyxinmsgpack._packer.Packer._pack (msgpack\_packer.cpp:220)()
TypeError: can'tserialize1213771In [5]: msgpack.packb([np.int32(1213771)])
Out[5]: '\x91\xce\x00\x12\x85K'In [6]: msgpack.packb([np.float64(1213771)])
Out[6]: '\x91\xcbA2\x85K\x00\x00\x00\x00'
The text was updated successfully, but these errors were encountered:
I found these strange corner cases when serializing np.float32 and np.int64 values. What's strange is that np.int32 and np.float64 for the same underlying value works.
Any ideas whats going on? ❓
The text was updated successfully, but these errors were encountered: