Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with unpacking packed multi-dimensional array #56

Open
Bomsw opened this issue Jul 21, 2024 · 1 comment
Open

Problem with unpacking packed multi-dimensional array #56

Bomsw opened this issue Jul 21, 2024 · 1 comment

Comments

@Bomsw
Copy link

Bomsw commented Jul 21, 2024

I've been trying to use the package to work with some multi-dimensional numpy arrays, unfortunately it does not seem to work

>>> import numpy as np
>>> import msgpack_numpy
>>> packed = msgpack_numpy.packb(np.ones((3,3)))
>>> msgpack_numpy.unpackb(packed)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/msgpack_numpy.py", line 287, in unpackb
    return _unpackb(packed, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/msgpack/fallback.py", line 121, in unpackb
    ret = unpacker._unpack()
  File "/usr/local/lib/python3.9/dist-packages/msgpack/fallback.py", line 602, in _unpack
    ret = self._object_hook(ret)
  File "/usr/local/lib/python3.9/dist-packages/msgpack_numpy.py", line 103, in decode
    return np.ndarray(buffer=obj[b'data'],
TypeError: buffer is too small for requested array

I am using numpy 1.24.4, msgpack-numpy 0.4.8 and msgpack 0.5.6 on python 3.9.5

@lebedov
Copy link
Owner

lebedov commented Jul 22, 2024

I can't seem to reproduce this:

pip freeze | egrep '(msgpack-numpy|msgpack-python|numpy)'
msgpack-numpy==0.4.8
msgpack-python==0.5.6
numpy==1.24.4python --version
Python 3.9.5python -c 'import msgpack_numpy, numpy; x=numpy.ones((3,3)); s=msgpack_numpy.packb(x); print(msgpack_numpy.unpackb(s))'
[[1. 1. 1.]
 [1. 1. 1.]
 [1. 1. 1.]]

Can you try reinstalling all of the packages (msgpack-python, numpy, msgpack-numpy) from scratch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants