Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Inherit SS bodies from Body #760

Closed
wants to merge 1 commit into from

Conversation

jorgepiloto
Copy link
Member

Solves #759 🚀

@jorgepiloto
Copy link
Member Author

Not sure why the test_orbit_is_pickable fails 😕

@astrojuanlu
Copy link
Member

Something broke at the bodies level:

In [1]: import pickle                                                                                                                                         

In [2]: from poliastro.bodies import Sun                                                                                                                      

In [3]: t = pickle.dumps(Sun)                                                                                                                                 

In [4]: pickle.loads(t)                                                                                                                                       
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-2b29055027ec> in <module>
----> 1 pickle.loads(t)

~/.pyenv/versions/3.7.3/envs/poliastro37/lib/python3.7/site-packages/astropy/constants/constant.py in wrapper(self, *args, **kwargs)
     35             @functools.wraps(meth)
     36             def wrapper(self, *args, **kwargs):
---> 37                 name_lower = self.name.lower()
     38                 instances = self._registry[name_lower]
     39                 if not self._checked_units:

AttributeError: 'NoneType' object has no attribute 'lower'

@astrojuanlu
Copy link
Member

Interestingly, it's something with the constants:

In [22]: b = Body(None, 1.0, "Body")                                                                                                                          

In [23]: t = pickle.dumps(b)                                                                                                                                  

In [24]: q = pickle.loads(t)                                                                                                                                  

In [25]: b                                                                                                                                                    
Out[25]: Body (None)

In [26]: q                                                                                                                                                    
Out[26]: Body (None)

In [27]: b = Body(None, Sun.k, "Body")                                                                                                                        

In [28]: t = pickle.dumps(b)                                                                                                                                  

In [29]: q = pickle.loads(t)                                                                                                                                  
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-29-f28dafaa6051> in <module>
----> 1 q = pickle.loads(t)

~/.pyenv/versions/3.7.3/envs/poliastro37/lib/python3.7/site-packages/astropy/constants/constant.py in wrapper(self, *args, **kwargs)
     35             @functools.wraps(meth)
     36             def wrapper(self, *args, **kwargs):
---> 37                 name_lower = self.name.lower()
     38                 instances = self._registry[name_lower]
     39                 if not self._checked_units:

AttributeError: 'NoneType' object has no attribute 'lower'

And, in fact:

astropy/astropy#9139

@astrojuanlu
Copy link
Member

With your permission, this will be superseded by #763. Let's find a simpler workaround in the meanwhile if you need this for #747, or wait until we merge the big refactor.

@jorgepiloto
Copy link
Member Author

I will wait to fully implement SSO orbits until #763 is ready to be merged since it is critical. For the moment I am reviewing all the new reformat and checking differents data and tests 😉

@jorgepiloto jorgepiloto deleted the bodies branch August 21, 2019 13:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants