lebedov / msgpack-numpy

Serialize numpy arrays using msgpack
Other
197 stars 33 forks source link

0.4.4.1 Cannot dump incontiguous array #34

Closed ppwwyyxx closed 5 years ago

ppwwyyxx commented 5 years ago
import numpy as np
import msgpack
import msgpack_numpy
msgpack_numpy.patch()

x = np.zeros((128, 128))
y = x[10:100, 10:100]

msgpack.dumps(y)

Run with python3, and msgpack-numpy 0.4.4.1 (latest), it fails with:

Traceback (most recent call last):
  File "a.py", line 12, in <module>
    msgpack.dumps(y)
  File "HOME/.local/lib/python3.6/site-packages/msgpack_numpy.py", line 196, in packb
    return Packer(**kwargs).pack(o)
  File "msgpack/_packer.pyx", line 284, in msgpack._packer.Packer.pack
  File "msgpack/_packer.pyx", line 290, in msgpack._packer.Packer.pack
  File "msgpack/_packer.pyx", line 287, in msgpack._packer.Packer.pack
  File "msgpack/_packer.pyx", line 234, in msgpack._packer.Packer._pack
  File "msgpack/_packer.pyx", line 266, in msgpack._packer.Packer._pack
BufferError: memoryview: underlying buffer is not C-contiguous

However the same code works for 0.4.3.1

lebedov commented 5 years ago

Fixed.