jotaylor / SPAMM

Spectral Properties of AGN Modeled through MCMC
BSD 3-Clause Clear License
1 stars 2 forks source link

Unable to pickle Model instance with new specutils version #27

Open jotaylor opened 5 years ago

jotaylor commented 5 years ago

The refactored specutils version uses Tabular1D in wcs_wrapper: https://github.com/astropy/specutils/blob/26d80182b10a62f064caa619363d520cdc944e66/specutils/wcs/wcs_wrapper.py#L58 But Tabular1D can't be pickled

> this = Tabular1D(np.arange(10), np.arange(10))                                                                                                             

> pickle.dump(this, open("tester.p", "wb"))                                                                                                                  
---------------------------------------------------------------------------
PicklingError                             Traceback (most recent call last)
<ipython-input-21-fd38e6f8bdb3> in <module>
----> 1 pickle.dump(this, open("tester.p", "wb"))

PicklingError: Can't pickle <class 'abc.Tabular1D'>
Name: Tabular1D
Inputs: ('x0',)
Outputs: ('y',): attribute lookup Tabular1D on abc failed

This problem propagates all the way through so that when a Model instance is returned by SPAMM, it cannot be pickled. This is a really big deal, since there's a ton of information stored in Model and the emcee.sampler instance. I tried saving Model as a json, but nothing worked.

jotaylor commented 5 years ago

I found a hacky solution to this, which is to say I just removed Tabular1D from specutils. Pretty sure the WCS object created in wcs_wrapper isn't correct, but that doesn't really matter for now. Fix is available here: https://github.com/jotaylor/specutils/tree/spamm