sot / Quaternion

Quaternion manipulation
https://sot.github.io/Quaternion
BSD 3-Clause "New" or "Revised" License
3 stars 7 forks source link

Properly unpickle quaternions from versions earlier than 3.5 #28

Closed javierggt closed 4 years ago

javierggt commented 4 years ago

Description

This is described in issue #27.

Testing

Fixes #27

taldcroft commented 4 years ago

You need to make sure the data are packaged in the distribution using package_data in setup().

One other question, how was the 3.4.1 Quat prepared? It would seem to matter a bit whether the hidden attributes were defined with values or None. There should be at least one test quaternion with all hidden values defined and one with at least some of them being None.

javierggt commented 4 years ago

One other question, how was the 3.4.1 Quat prepared? It would seem to matter a bit whether the hidden attributes were defined with values or None. There should be at least one test quaternion with all hidden values defined and one with at least some of them being None.

I just checked in a file generated like this:

from Quaternion import Quat
import pickle
q = Quat([10., 20., 30.])
quats = [Quat(q.q), Quat(q.transform), Quat(q.equatorial)]
quats.append(q)
with open('quaternion-v3.4.1.pkl', 'wb') as f:
    pickle.dump(quats, f)

They are all the same quat with different internal representations, they are all tested against the same values. I could not create a Quat with all hidden values None, because the constructor argument is required.

taldcroft commented 4 years ago

Perfect. So can you just add a docstring to the test function that says basically:

Pickle file generated using Quaternion v3.4.1:

from Quaternion import Quat
import pickle
q = Quat([10., 20., 30.])
quats = [Quat(q.q), Quat(q.transform), Quat(q.equatorial)]
quats.append(q)
with open('quaternion-v3.4.1.pkl', 'wb') as f:
    pickle.dump(quats, f)
taldcroft commented 4 years ago

Did anybody do an install test?

jeanconn commented 4 years ago

I did not. I just added the repo to my PYTHONPATH to double check my use case.

javierggt commented 4 years ago

I don't remember if I did it then, but I just did it, just in case. In this case, the install test was to verify that test data file is installed, so I ran the unit tests.

javierggt commented 4 years ago

the question is which install test you want.

taldcroft commented 4 years ago

Install the package and verify that tests pass using the installed version not from git repo.

javierggt commented 4 years ago

yes, that's what I did. I installed doing pip install . (not python setup.py install)