Skip to content

Fix writing non contiguous data to a compressed HDU. - #9958

Merged
pllim merged 2 commits into
astropy:masterfrom
saimn:fits-compressed
Feb 20, 2020
Merged

pllim merged 2 commits into
astropy:masterfrom
saimn:fits-compressed

Conversation

@saimn

@saimn saimn commented Feb 19, 2020 •

Copy link
Copy Markdown
Contributor

Fixes #2150 and fixes #9955.

@saimn saimn added the io.fits label Feb 19, 2020
@saimn saimn added this to the v4.0.1 milestone Feb 19, 2020
@saimn
saimn requested a review from MSeifert04 February 19, 2020 03:46
Comment thread astropy/io/fits/tests/test_image.py
@pllim pllim added the Bug label Feb 19, 2020

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @saimn !

cc @pchanial and @Pharisaeus

Comment thread CHANGES.rst Outdated
@bsipocz

bsipocz commented Feb 19, 2020

Copy link
Copy Markdown
Member

Always great to see when a super old issue is being fixed :) Thanks @saimn!

@MSeifert04 MSeifert04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

It's a bit weird to do a copy (in-place). But currently it's writing weird data (if I recall correctly) so this is an immense improvement.

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

hdulist.writeto(self.temp('test.fits'))

actual = fits.getdata(self.temp('test.fits'))
assert_equal(orig, actual)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if exact match required for floating point comparison will come back to bite us, but let's leave it as-is for now.

Suggested change
assert_equal(orig, actual)
assert_equal(orig, actual)

@pllim
pllim merged commit aa3856e into astropy:master Feb 20, 2020
@saimn
saimn deleted the fits-compressed branch February 20, 2020 19:21
@saimn

saimn commented Feb 20, 2020 •

Copy link
Copy Markdown
Contributor Author

@MSeifert04 - The original data is restored after it has been written, and yes that means that a copy is done when the data is noncontiguous, but doing something more efficient is more difficult (#3895).

bsipocz pushed a commit that referenced this pull request Feb 21, 2020
Fix writing non contiguous data to a compressed HDU.
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.

Invalid cutout/slice data for rice tile compressed images. Pyfits: Incorrect writing of non contiguous data in compressed FITS

4 participants