You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Jerry-Ma - thanks for reporting! So, if I understand correctly, the actual problem is not specific to dill but really that an unbound info cannot be pickled, i.e., that the following fails:
import pickle
from astropy.utils.data_info import DataInfo
di = DataInfo()
pickle.dumps(di)
AttributeError: 'DataInfo' object has no attribute '_attrs'
I think your fix seems logical (though perhaps an alternative is to always set _attrs, maybe _attrs=None for the unbound case? your fix has the advantage of not changing any other behaviour, though). Would you be willing to make a PR? I think the test would just be with pickle on DataInfo rather than with dill on Masked - I don't think we want to add another dependency just for the tests if we can avoid it!
Aside - it is a bit curious that Masked instances can be pickled, i.e., pickle clearly does something a bit different from dill - this suggests that perhaps there is a bug in dill? Or is this an expected difference?
Description
It appears that the following code to pickle a
MaskedQuantity
object does not work because the__setstate__
does not handle non-bound case:The fix seems to be simple: add logic to handle the uninitialized
_attrs
attribute on theastropy.utils.data_info.DataInfo
class:Any additional thoughts or caveats?
Expected behavior
The above code works without error.
How to Reproduce
No response
Versions
The text was updated successfully, but these errors were encountered: