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
Issues when deserializing numpy.poly1d
#391
Comments
I'm not very familiar with the numpy extension, however it seems like a bug that poly1d isn't working properly. The recommended way to deal with all numpy primitives in jsonpickle is to use the numpy extension. Can you provide a full set of sample code to reproduce this? I see the serialized data, thanks, but can you provide the code you used to call the deserializer plus any classes that would be required to deserialize this? |
Also, based on the directory names of your traceback, if you're using jsonpickle to transfer data over a socket for an emulator, I'd recommend using something else (for performance reasons). Unless it's critical that someone capturing + reading the packets knows what the data inside is (like for debugging purposes), then use cPickle. cPickle is a much faster format for (de)serialization, plus serialized objects take up much less space and therefore use less bandwidth when transferred over a network. Additionally, it's builtin to python. The only disadvantage I can think of is that the produced data isn't always compatible between different python versions. |
Here is the example code that triggers the bug: import jsonpickle
import numpy
from jsonpickle.ext.numpy import register_handlers
register_handlers()
jsonpickle.decode(jsonpickle.encode(numpy.poly1d([1, 2, 3]))) |
Also thanks you for your input regarding the choice of serialization library. Currently, our communication overhead is very small compared to our computation time. But I will keep your suggestion in mind 🙂 What I like about |
Thank you for the example code, I'll try some debugging now.
Oh yeah, introspection is an amazing advantage of`jsonpickle. I had to parse encoded data in a different language at one point and it was so much easier than if I had gone with cPickle or something else. Good luck with your emulator! |
This will be fixed in jsonpickle 3.0, however it may be a while before that is released. In the meantime, feel free to use |
I want to transfer an object containing a
numpy.poly1d
property using jsonpickle. Is this something that could be enabled byjsonpickle
and its numpy extension or is the recommended way to treat this within__getstate__
and__setstate__
?Either way, I would have expected that unsupported attributes (like
numpy.poly1d
seems to be) would be stripped during serialization, so that they cannot cause issues during deserialization.The serialized data and the traceback I am getting:
The text was updated successfully, but these errors were encountered: