-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
FITS_rec objects can be pickled with this patch #2193
Conversation
Thanks for the fix! @embray can review and provide advice about the test. |
I'll have to take a closer look at this. I feel like the solution may be simpler than this but I don't know for sure. |
To be honest I thought it was an easy patch to do, but it took me much longer to figure out a way to fix it that I thought. |
Sorry I've been slow to respond on this--I have to say it looks good minus a few trivial nitpicks. I just don't fully understand the issue or how exactly this fixes it and need to find time to take a closer look. Hopefully I'll get to that soon since this is very much a bug that needs fixing, and your PR is probably mostly good! |
super(FITS_rec, self).__setstate__(state) | ||
|
||
for i in range(len(meta)): | ||
setattr(self, meta[i], column_state[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be rewritten:
for attr, value in zip(meta, column_state):
setattr(self, attr, value)
to me that's a little clearer as to what's going on.
Thanks, this seems to solve the problem fairly straightforwardly and (I think--I still haven't investigated deeply) correctly. Please address the notes I made in the code and please also add some regression tests in the There are already some sample tables included in the test modules that can be accessed via Thanks! |
Thanks for the review @embray. I try to clean this up and add tests later this week. |
I have a slightly related question. Do we want to pickle |
meta = [] | ||
|
||
for attrs in ['_convert', '_heapoffset', '_heapsize', '_nfields', '_gap', | ||
'_uint', 'names', 'formats', 'parnames', '_coldefs']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure how I feel about including 'parnames' here But on the same token, nobody outside of PyFITS itself is expected to ever subclass FITS_rec
so I'm okay with it for now, especially considering the intention to eventually remove it anyway.
Just needs one small update to the tests and a changelog entry and should be good to go--thanks! |
@bsipocz - it looks like this will need rebasing - thanks! |
@bsipocz There's a test errors on Python 3. Can you have a look? |
Ah, I've run into this problem before with pickle on Python 3--this is due to the new new pickle protocol used as the default in newer Python versions. I believe the solution is to provide a |
It looks similar to the problem in #2123. |
@bsipocz Are you on Mac or Linux?
Some Linuxes also have |
I should have checked the new comments first. Sorry for duplicating it @embray. |
That's okay--good to see you were already on it. But yeah, for development on Astropy I would definitely recommend at least having one Python 3 version available--preferably 3.3. |
Thanks for the tips @cdeil . Let's see whether Travis likes it, too. |
The travis-ci error is unrelated ... @embray or @astrofrog could you please restart the build? Otherwise I think this is ready for final review by @embray. |
I use eric4 for python2.7, but eric5 didn't build because of some non trivial dependency issues. I'll definitely sort it out for the long turn, I'm just short of time at the moment. |
Okay, I'm satisfied. Thanks @bsipocz ! |
FITS_rec objects can be pickled with this patch
FITS_rec objects can be pickled with this patch
This is a PR to fix issue #1597. It seems working to me (pickled a few different fits tables with it), but please advise how it should be tested properly.