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

Use bytes on pickle SpatialPooler and TemporalMemory #530

Merged
merged 6 commits into from
Jul 1, 2019

Conversation

Lupino
Copy link

@Lupino Lupino commented Jun 26, 2019

Fixed UnicodeDecodeError, when pickle SpatialPooler or TemporalMemory

#160

@breznak breznak added fix python not py binding, but merge py code in repo serializable SP TM labels Jun 26, 2019
@breznak breznak added Python Binding and removed python not py binding, but merge py code in repo labels Jun 26, 2019
Copy link
Member

@breznak breznak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Lupino 👍
this looks good!
Can you please add/enable the tests which use pickle serialization to show this is working?

@ctrl-z-9000-times
Copy link
Collaborator

Hi Lupino,

I think I know why you code does not work. It looks like a problem with pybind11 and python2. I found this thread discussing it: pybind/pybind11#271

Try replacing import pickle with:

try:
    import cPickle as pickle # For python 2
except ImportError:
    import pickle # For python 3

@Lupino
Copy link
Author

Lupino commented Jun 29, 2019

Hi Lupino,

I think I know why you code does not work. It looks like a problem with pybind11 and python2. I found this thread discussing it: pybind/pybind11#271

Try replacing import pickle with:

try:
    import cPickle as pickle # For python 2
except ImportError:
    import pickle # For python 3

I changed but also failed

@Lupino
Copy link
Author

Lupino commented Jun 29, 2019

@ctrl-z-9000-times
Copy link
Collaborator

I think that the next best thing would be to detect which version of python is running and skip the unit tests if it's python 2. Then at least we can have this working and tested for python3.

The pytest docs have some examples of how to do this:
https://docs.pytest.org/en/latest/skipping.html?highlight=skipping#id1

@breznak
Copy link
Member

breznak commented Jul 1, 2019

This ended up a really nice PR! Thank you @Lupino 👍

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

Successfully merging this pull request may close these issues.

3 participants