Skip to content

Fix issues with mixins serialization and FITS#10485

Merged
taldcroft merged 5 commits intoastropy:masterfrom
saimn:fits-table-mixin
Jun 18, 2020
Merged

Fix issues with mixins serialization and FITS#10485
taldcroft merged 5 commits intoastropy:masterfrom
saimn:fits-table-mixin

Conversation

@saimn
Copy link
Contributor

@saimn saimn commented Jun 12, 2020

Fix #7783 and fix #7364.

@saimn saimn added this to the v4.0.2 milestone Jun 12, 2020
@saimn saimn requested a review from taldcroft June 12, 2020 00:04
@pllim pllim added the Bug label Jun 12, 2020
Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saimn - thanks! This looks great and I just have a small request for a test change or adding a code comment.


@pytest.mark.skipif('HAS_YAML')
def test_warn_for_dropped_info_attributes(tmpdir):
def test_warn_for_dropped_info_attributes(tmpdir, monkeypatch):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I didn't know about monkeypatch.


# Copy the meta dict if it was not copied by represent_mixins_as_columns
if encode_tbl is tbl:
meta_copy = deepcopy(tbl.meta)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance I thought it might be possible to get away without doing a deep copy here. (I have spent a lot of time getting rid of unnecessary deep copies of meta, related to a project where I put a lot of stuff into meta.) But looking more carefully I saw that if the input table had a pre-existing comments list in meta, then that would get updated in place and impact the original meta.

So it might be worth adding a comments key like ['a', 'b'] in the test below. This will then fail if a future maintainer comes along and makes the mistake I almost made. Or at least put in a comment here about why the deepcopy is really necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points, thanks, I did the changes.

Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@taldcroft taldcroft merged commit 316eff3 into astropy:master Jun 18, 2020
@saimn saimn deleted the fits-table-mixin branch June 18, 2020 14:04
astrofrog pushed a commit that referenced this pull request Jul 16, 2020
Fix issues with mixins serialization and FITS
astrofrog pushed a commit that referenced this pull request Jul 16, 2020
Fix issues with mixins serialization and FITS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table.read on FITS file triggers PyYAML import Table write to FITS adds comments to meta

3 participants