Skip to content

Commit 1153e3d

Browse files
committed
Borrows a change that was also made in #3916 which also happens to fix #3766; included a regression test.
1 parent 0307e68 commit 1153e3d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎astropy/io/fits/hdu/image.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ def _get_scaled_image_data(self, offset, shape):
585585
raw_data = self._get_raw_data(shape, code, offset)
586586
raw_data.dtype = raw_data.dtype.newbyteorder('>')
587587

588-
if (self._orig_bzero == 0 and self._orig_bscale == 1 and
589-
self._blank is None):
588+
if ((self._orig_bzero == 0 and self._orig_bscale == 1 and
589+
self._blank is None) or self._do_not_scale_image_data):
590590
# No further conversion of the data is necessary
591591
return raw_data
592592

‎astropy/io/fits/tests/test_core.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,3 +1122,8 @@ def test_error_if_memmap_impossible(self):
11221122
pth = self.data('blank.fits')
11231123
with pytest.raises(ValueError):
11241124
fits.open(pth, memmap=True)[0].data
1125+
1126+
# However, it should not fail if do_not_scale_image_data was used:
1127+
# See https://github.com/astropy/astropy/issues/3766
1128+
hdul = fits.open(pth, memmap=True, do_not_scale_image_data=True)
1129+
hdul[0].data # Just make sure it doesn't crash

0 commit comments

Comments
 (0)