lebedov/msgpack-numpy

structured array issue

cycomanic opened this issue · 1 comments

if I try to pack/unpack the following structured array I get ValueError. I saw some tests on structured arrays in the code, so I assume they work (maybe it's because I have an array inside the structured array?).

In [10]: x=np.array([(1, 2.3, np.arange(10.))], dtype=[('num', np.int32), ('flo', np.float64), ('arr', np.float64, (10))])
In [11]: s=msgpack.packb(x)
In [12]: o=msgpack.unpackb(s)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-f6dc2c41c01d> in <module>()
----> 1 o=msgpack.unpackb(s)

/home/jschrod/.local/lib/python3.5/site-packages/msgpack_numpy.py in unpackb(packed, object_hook, encoding, **kwargs)
    185 
    186     kwargs['object_hook'] = object_hook
--> 187     return _unpacker.unpackb(packed, encoding=encoding, **kwargs)
    188 
    189 load = unpack

msgpack/_unpacker.pyx in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:2068)()

/home/jschrod/.local/lib/python3.5/site-packages/msgpack_numpy.py in decode(obj)
     82                     descr = obj[b'type']
     83                 return np.fromstring(obj[b'data'],
---> 84                             dtype=np.dtype(descr)).reshape(obj[b'shape'])
     85             else:
     86                 descr = obj[b'type']

ValueError: invalid shape in fixed-type tuple.

Fixed on GitHub.